通过VBA

时间:2017-11-05 10:40:59

标签: vba outlook outlook-vba

我尝试使用VBA在Outlook电子邮件中创建表。我知道我们可以使用带有表格选项卡的Html体来创建表格。像下面的代码

Sub Test  
    Set oolApp = CreateObject("Outlook.Application")
    Set Email = oolApp.CreateItem(0)

    Dim MailBody As String
    MailBody = "<table border=1>"
    MailBody = MailBody & "<tr><td>" & "aaa" & "</td>" & "<td>" & "bbb" & "</td>" & "<td>" & "bbb" & "</td></tr>"
    MailBody = MailBody & "<tr><td>" & "123" & "</td>" & "<td>" & "456" & "</td>" & "<td>" & "789" & "</td></tr>"
    MailBody = MailBody & "</table>"

    Email.HTMLBody = MailBody

    Email.display   

End Sub

但是我想在Table Tool中使用模板表 - &gt;设计使桌子更美观。无论如何都要使用VBA代码。

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以手动创建表并另存为.oft文件。

Option Explicit

Sub ThreeColumnGreenStripeTable

    Dim Email as mailitem
    Set Email = CreateItemFromTemplate("path to ThreeColumnGreenStripeTable.oft")
    Email.display   

End Sub