在VB.net中使用表发送Outlook电子邮件

时间:2016-12-21 19:36:54

标签: vb.net email outlook

我使用以下代码生成并打开Outlook电子邮件。但是我需要能够插入一个包含一些变量的表,而我当前的方法只允许基本文本,任何人都可以提出一种方法来集成表格吗?

  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

以下是表格需要的示例:

enter image description here

显然,Outlook使用了格式化代码,但我不知道如何将其从visual basic发送到电子邮件中。

1 个答案:

答案 0 :(得分:0)

首先从代码中获取DoEvents()。他们没有任何帮助。

对于表,最简单的方法是将消息体构建为包含表的HTML字符串。当然,这需要电子邮件集的接收者接受HTML。