Email BODY error lines all in red

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,036
Hi Please can you help on the code below, this is in my command button but the email body is all in red, please can you help?
Code:
Private Sub CommandButton3_Click()
Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String
Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)
        aEmail.htmlBody = "Hi There," & Chr(10) & vbCrLf &_
                      "<p>MPAN / MPRN: " & Chr(10) & _
                      "</p><p>Post Code: " & Chr(10) & _
                      "</p><p><b>Comments: </b> " & Chr(10) & _
                      "<p>Job Type: " & & Chr(10) & vbCrLf & _
                      "<p></p>Many thanks " & Chr(10) &
        aEmail.Recipients.Add (Worksheets("Email Links").Range("A2").Value)
    
        aEmail.CC = ""
        aEmail.BCC = ""
        aEmail.Subject = "AMR - 2 Man Request"
        aEmail.Display

End Sub
 

Some videos you may like

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

KOKOSEK

Board Regular
Joined
Apr 8, 2019
Messages
206
Office Version
365, 2013
Platform
Windows
Try like this:

Code:
Private Sub CommandButton3_Click()

Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String
Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)
    With aEmail
        .htmlBody = "Hi There,<br><br>" & _
        "MPAN / MPRN: <br>" & _
        "Post Code: <br>" & _
        "Comments:  <br>" & _
        "Job Type: <br><br><br>" & _
        "Many thanks <br>"
        .To = Worksheets("Sheet1").Range("A2").Value
        .CC = ""
        .BCC = ""
        .Subject = "AMR - 2 Man Request"
        .Display
    End With


End sub
 
Last edited:

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,036
Hi this is great thank you, please can you advise how I can get a line break inbetween each line.
Please can you advise where I went wrong as well please?
 

KOKOSEK

Board Regular
Joined
Apr 8, 2019
Messages
206
Office Version
365, 2013
Platform
Windows
.htmlBody so you can format text in email like html. So any additional breakline is <br>
 

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,036
hi I have done like the below for example but it doesn't work.

HTML:
Private Sub CommandButton3_Click()
Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String
Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)
    With aEmail
        .htmlBody = "Hi There,</br>" & _
        "<br>MPAN / MPRN: </br>" & _
        "Post Code: " & _
        "Comments:  " & _
        "Job Type: " & _
        "Many thanks "
        .To = Worksheets("Email Links").Range("A2").Value
        .CC = ""
        .BCC = ""
        .Subject = "AMR - 2 Man Request"
        .Display
    End With
End Sub
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,095,481
Messages
5,444,736
Members
405,298
Latest member
fxtrtr17

This Week's Hot Topics

Top