如何将项目符号添加到电子邮件模板的.Body部分?

问题描述 投票:1回答:1

如何将项目符号添加到电子邮件模板的.Body部分?

我希望我的电子邮件正文如下所示:


已附上DATE AM的文档。

已邮寄

  • 3个文档

已接收

  • 7个文档

我当前的代码在下面,除非在邮件和接收的单词下面没有多余的空格:

Sub CreateNewMail()
    Dim obApp As Object
    Dim NewMail As MailItem

    Set obApp = Outlook.Application
    Set NewMail = obApp.CreateItem(olMailItem)

    'You can change the concrete info as per your needs
    With NewMail
        .Subject = "Docs " & Format(Date, "m.d.yy") & " AM"
        .To = 
        .Body = "Attached are the docs for " & Format(Date, "m.d.yy") & " AM" & vbNewLine & vbNewLine _
          & "Mailed" & vbNewLine & vbNewLine _
          & "Received"
         .Display
    End With

    Set obApp = Nothing
    Set NewMail = Nothing
End Sub

我对VBA还是陌生的。我搜索了论坛,但找不到所需的内容。

html vba outlook outlook-2010 bulletedlist
1个回答
0
投票

如前所述,您将需要使用.HTMLBody而不是.Body可以轻松实现的HTML。如果您只需要几个子弹,就可以使其简单。这应该使您入门。您想要一个无序列表<ul>,您将向其中添加列表项<li>

Sub CreateNewMail()
Dim obApp As Object
Dim NewMail As MailItem

Set obApp = Outlook.Application
Set NewMail = obApp.CreateItem(olMailItem)

'You can change the concrete info as per your needs
With NewMail
     .Subject = "Docs " & Format(Date, "m.d.yy") & " AM"
     .To = "Mr Nobody"
     .HTMLBody = "Attached are the docs for " & Format(Date, "m.d.yy") & " AM" & _
     "<p>Mailed</p>" & _
     "<ul><li>3 Documents</li></ul>" & _
     "<p>Received</p>" & _
     "<ul><li>7 Documents</li></ul>"
     .Display
End With

Set obApp = Nothing
Set NewMail = Nothing
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.