Email BODY error lines all in red

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
Office Version
  1. 2010
Platform
  1. Windows
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
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
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:
Upvote 0
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?
 
Upvote 0
.htmlBody so you can format text in email like html. So any additional breakline is <br>
 
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,718
Members
448,986
Latest member
andreguerra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top