1

How do I add bullets into the .Body section of an email template?

I want my email body to look like below:


Attached are the docs for DATE AM.

Mailed

  • 3 documents

Received

  • 7 documents

My current code is below, except without the extra space underneath the words Mailed and Received:

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

I am fairly new to VBA. I searched forums but I can't find what I need.

Community
  • 1
  • 1
Bibo895
  • 21
  • 3

1 Answers1

0

As mentioned you will need to use HTML which can easily be achieved using .HTMLBody instead of .Body. If all you need is a couple of bullets, you can keep it simple. This should get you started. You want an unordered list <ul> to which you will add a list item <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
ACCtionMan
  • 511
  • 1
  • 3
  • 12