I'm using the following code to generate and open an Outlook E-Mail. However I need to be able to insert a table with some variables and my current method only allows for basic text, could anyone suggest a way in which I could integrate a table?
Try
lblStatus.Text = "Opening OutLook Mail, Please Wait..."
My.Application.DoEvents
Dim Outl As Object
Outl = CreateObject("Outlook.Application")
If Outl IsNot Nothing Then
Dim omsg As Object
omsg = Outl.CreateItem(0)
omsg.body = "Table should go here"
omsg.To = "*address goes here"
omsg.subject = SubjectLine
'set message properties here...'
omsg.Display(false) 'will display message to user
lblStatus.Text = "Outlook Mail Template Opened."
My.Application.DoEvents
End If
Catch ex As Exception
lblStatus.Text = "Opening OutLook Mail | Error Encountered"
My.Application.DoEvents
'log error
End Try
Here's an example of what the table needs to be like:
Obviously there's formatting code used by Outlook, but I don't know how to send that from visual basic into the email.
First get the DoEvents() out of your code. They are not helping anything.
As for the table, the simplest way to do it is to build the message body as a HTML string that includes the table. Of course, that requires the receiver of the email set to accept HTML.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.