VBA Outlook Signature Formatting

2000km12

New Member
Joined
Apr 19, 2023
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hello, I am attempting to insert my default signature at the bottom of some automatically generated email. The contents of my signature have been copied, however, it lost the formatting. Here is the code I used.




Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
.Display
End With

signature2 = OutMail.Body

With OutMail
.Subject = "Reminder - CAR(s) Upcoming Due Dates"
.To = sht.Range("B" & Rw).Value
.CC = "Example Name"

.HTMLBody = "Good Morning," & "<br>" & "<br>" & "This is a friendly reminder that you have a Corrective Action due in " & "<b>" _
& "two business days." & "</b>" & " Please let me or Example Name know if you require any additional support or would like to" _
& " request an extension." & "<br>" & "<br>" & "<b>" & "<u>" & "<span style='background:yellow;mso-highlight:yellow'>" & _
"Please request an extension today or tomorrow; extensions cannot be requested the day the action is due." & _
"</span>" & "</b>" & "</u>" & "<br>" & "<br>" & "<br>" & RangetoHTML(rngHeader) & RangetoHTML(rng) & "<br>" & "<br>" & "Thank You," & _
"<br>" & "<br>" & signature2

.Display
End With
Set OutApp = Nothing
Set OutMail = Nothing


My signature is appearing as one line with no bolding.
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Forgetting about saving the signature and try modifying your code as follows:
Rich (BB code):
.HTMLBody = "Good Morning," & "<br>" & "<br>" & "This is a friendly reminder that you have a Corrective Action due in " & "<b>" _
& "two business days." & "</b>" & " Please let me or Example Name know if you require any additional support or would like to" _
& " request an extension." & "<br>" & "<br>" & "<b>" & "<u>" & "<span style='background:yellow;mso-highlight:yellow'>" & _
"Please request an extension today or tomorrow; extensions cannot be requested the day the action is due." & _
"</span>" & "</b>" & "</u>" & "<br>" & "<br>" & "<br>" & RangetoHTML(rngHeader) & RangetoHTML(rng) & "<br>" & "<br>" & "Thank You," & _
"<br>" & "<br>" & .HTMLBody
 
Upvote 1
Solution
Forgetting about saving the signature and try modifying your code as follows:
Rich (BB code):
.HTMLBody = "Good Morning," & "<br>" & "<br>" & "This is a friendly reminder that you have a Corrective Action due in " & "<b>" _
& "two business days." & "</b>" & " Please let me or Example Name know if you require any additional support or would like to" _
& " request an extension." & "<br>" & "<br>" & "<b>" & "<u>" & "<span style='background:yellow;mso-highlight:yellow'>" & _
"Please request an extension today or tomorrow; extensions cannot be requested the day the action is due." & _
"</span>" & "</b>" & "</u>" & "<br>" & "<br>" & "<br>" & RangetoHTML(rngHeader) & RangetoHTML(rng) & "<br>" & "<br>" & "Thank You," & _
"<br>" & "<br>" & .HTMLBody
This worked perfectly! Thank you very much!!
 
Upvote 0

Forum statistics

Threads
1,215,262
Messages
6,123,935
Members
449,134
Latest member
NickWBA

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