I have just started to use VBA in order to send emails in batches and I just have a problem because there is an extra line between the last sentence and the signature.
This is how it looks:
Dear Mr. Example 2,
message 1
message 2
Congratulations!
Space
Space
Signature
I have done a research in different forums but I couldn't find any solution to it.
Thank you in advance for your support!
This is the code I'm using:
Option Explicit
Sub Example()
Dim olApp As Object
Dim olMail As Object
Dim olRecip As Object
Dim olAtmt As Object
Dim iRow As Long
Dim Recip As String
Dim Subject As String
Dim Atmt As String
iRow = 2
Set olApp = CreateObject("Outlook.Application")
Do Until IsEmpty(Cells(iRow, 1))
Recip = Cells(iRow, 1).Value
Subject = Cells(iRow, 3).Value
Atmt = Cells(iRow, 4).Value ' Attachment Path
Set olMail = olApp.CreateItem(0)
With olMail
Set olRecip = .Recipients.Add(Recip)
.Display
.Subject = Subject
.HTMLbody = "<html><body><p>Dear " & Cells(iRow, 2).Value & "," & "<br>" & "<br>" & "message 1" & "<br>" & "<br>" & "message 2" & "<br>" & "<br>" & "Congratulations!" & .HTMLbody
Set olAtmt = .Attachments.Add(Atmt)
olRecip.Resolve
.Save
.Close 1
End With
iRow = iRow + 1
Loop
Set olApp = Nothing
Exit Sub
End Sub'
.....
– Luis Curado Sep 13 '18 at 15:07