I made a quick macro to help facilitate sending a standard email to a list of recipients.
This Macro looks at a list of recipients and sends a standard email body which is populated with a specific cell reference.
I originally just used the ".body = " method, which worked fine and would take line breaks from the referenced cell which is perfect.
However i want to switch to ".htmlbody = " so that the signature can have an image. Doing this however it seems to loose the inherrent formatting with the in referenced cell.
(I used 'alt+enter' in the corresponding cell to add line breaks)
how can i use .htmlbody to keep images in the signature, while still pulling the line breaks and formatting from the cell which cotains the email body text?
See the macro language (not html) below and thanks in advance!!
'This Macro sends a repeated email with updated subject and names
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
recipcount = Worksheets("Main").Range("E1")
'iterates through recipients
For i = 3 To (2 + recipcount)
'sets current recipient email address, cc emails and name
CurRecip = Worksheets("Main").Cells(i, 5)
CurCC = Worksheets("Main").Cells(i, 8)
CurRecipName = Worksheets("Main").Cells(i, 6)
Set OutMail = OutApp.CreateItem(0)
'creates 'Signature' using the default outlook signature
OutMail.display
Signature = OutMail.Body
'sends email to email address in the excel
With OutMail
'.display
.To = CurRecip
.cc = CurCC
.bcc = ""
.Subject = Worksheets("Main").Cells(4, 1) & " - " & Worksheets("Main").Cells(i, 7)
.Body = "Dear " & CurRecipName & vbNewLine & vbNewLine & Worksheets("Main").Cells(8, 1) & vbNewLine & vbNewLine & "Best," & Signature
' 'You can add other files also like this: .Attachments.Add ("C:\test.txt")
.display 'or use .send
End With
Set OutMail = Nothing
' MsgBox CurRecip
Next i
Set OutMail = Nothing
Set OutApp = Nothing
This Macro looks at a list of recipients and sends a standard email body which is populated with a specific cell reference.
I originally just used the ".body = " method, which worked fine and would take line breaks from the referenced cell which is perfect.
However i want to switch to ".htmlbody = " so that the signature can have an image. Doing this however it seems to loose the inherrent formatting with the in referenced cell.
(I used 'alt+enter' in the corresponding cell to add line breaks)
how can i use .htmlbody to keep images in the signature, while still pulling the line breaks and formatting from the cell which cotains the email body text?
See the macro language (not html) below and thanks in advance!!
'This Macro sends a repeated email with updated subject and names
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
recipcount = Worksheets("Main").Range("E1")
'iterates through recipients
For i = 3 To (2 + recipcount)
'sets current recipient email address, cc emails and name
CurRecip = Worksheets("Main").Cells(i, 5)
CurCC = Worksheets("Main").Cells(i, 8)
CurRecipName = Worksheets("Main").Cells(i, 6)
Set OutMail = OutApp.CreateItem(0)
'creates 'Signature' using the default outlook signature
OutMail.display
Signature = OutMail.Body
'sends email to email address in the excel
With OutMail
'.display
.To = CurRecip
.cc = CurCC
.bcc = ""
.Subject = Worksheets("Main").Cells(4, 1) & " - " & Worksheets("Main").Cells(i, 7)
.Body = "Dear " & CurRecipName & vbNewLine & vbNewLine & Worksheets("Main").Cells(8, 1) & vbNewLine & vbNewLine & "Best," & Signature
' 'You can add other files also like this: .Attachments.Add ("C:\test.txt")
.display 'or use .send
End With
Set OutMail = Nothing
' MsgBox CurRecip
Next i
Set OutMail = Nothing
Set OutApp = Nothing