Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create "table" for mailto: 1

Status
Not open for further replies.

Qik3Coder

Programmer
Jan 4, 2006
1,487
US
Let me start with I couldn't find a better way to do this.

I am prefilling a outlook email with some dynamically gen'ed tabular data. The preferred method would be to actually create a populate the table. Failing that i create a mailto: string and then send that to Process.Start(). I am padding the text to get close to table'ed but would like to know if there is a way to actually do this.
The tabs are being converted into spaces, which is messing with my layout.

Code so far:

Code:
Dim strEmail As String = "mailto:?"
With dgvData.Rows(0)
   strEmail += "SUBJECT=Information for " + .Cells("Name").Value.ToString
   strEmail += "&BODY="
   '...
   For inti As Integer = 1 To intAirline
      strEmail += "%09" '%09 is the symbol for tab
   Next
   '...
Process.Start(strEmail)
lblMessage.Text = "Email Generated"

As icky as it would be, if it was possible I would sendKeys the table creation, and data population.


Thanks in advance,
David

If [blue]you have problems[/blue], I want [green]source code[/green] AND [green]error messages[/green], none of this [red]"there was an error crap"[/red]
 
Here is a way to create HTML file from a DataTable. The same an be used for creating HTML mail.
Code:
    Public Sub ExportHTML(ByVal Table As DataTable, ByVal Location As String)

        Using Writer As New System.IO.StreamWriter(Location)

            Writer.WriteLine("<HTML>")
            Writer.WriteLine(" <HEAD>")
            Writer.WriteLine("  <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>")
            Writer.WriteLine(" </HEAD>")
            Writer.WriteLine(" <BODY>")
            Writer.WriteLine("<TABLE border='0'>")
            Writer.WriteLine(" <TR>")
            For Each Column As DataColumn In Table.Columns
                Writer.WriteLine("  <TD>" & Column.ColumnName & "</td>")
            Next
            Writer.WriteLine(" </TR>")
            For Each Row As DataRow In Table.Rows
                Writer.WriteLine(" <TR>")
                For Each Column As DataColumn In Table.Columns
                    Select Case Column.ColumnName
                        Case Is = "RecID"
                            Writer.WriteLine("  <TD width=50>" & Row.Item(Column).ToString & "</TD>")
                        Case Is = "UserName"
                            Writer.WriteLine("  <TD width=300>" & Row.Item(Column).ToString & "</TD>")
                        Case Is = "CompID"
                            Writer.WriteLine("  <TD width=100>" & Row.Item(Column).ToString & "</TD>")
                    End Select
                Next

                Writer.WriteLine(" </TR>")
            Next
            Writer.WriteLine("</TABLE>")
            Writer.WriteLine(" </BODY>")
            Writer.WriteLine("</HTML>")

        End Using

    End Sub


________________________________________________________
Zameer Abdulla
Help to find Missing people
 
I did that for the last thing i had to do, just creating a html file on the PC, and then opening it from there. This one actually needs to populate the email. I am going to try to hash out how to write the html to the email today, because it's not working just writing out the brackets.

Thanks,

If [blue]you have problems[/blue], I want [green]source code[/green] AND [green]error messages[/green], none of this [red]"there was an error crap"[/red]
 
Thanks ZmrAbdulla, for pointing me back at the HTML option.

Code:
 Dim a As New Microsoft.Office.Interop.Outlook.Application()
 Dim b As Microsoft.Office.Interop.Outlook.MailItem = _
     a.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
 b.To = "a@b.com"
 b.Subject = "stuff n things"
 b.HTMLBody = "<HTML><BODY><B>some text</B></BODY></HTML>"
 b.Display()

If [blue]you have problems[/blue], I want [green]source code[/green] AND [green]error messages[/green], none of this [red]"there was an error crap"[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top