VBA Add signature to Outlook e-mail

mssbass

Active Member
Joined
Nov 14, 2002
Messages
252
Platform
  1. Windows
Can anyone help add my signature to this VBA? It's currently creating the e-mail, adding my hyperlink and adding my cells requested to the body but I can't get the signature added at the bottom... When I open a blank e-mail, my signature is there.


Sub SendScrubFile()
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
Dim txtdate As String
Dim strbody As String
Dim strbody2 As String
Dim strbody3 As String
Dim strbody4 As String
Dim signature As String

Set rng = Nothing
On Error Resume Next

Set rng = wsstart.Range("c23:e31").SpecialCells(xlCellTypeVisible)

txtdate = Format(Now, "m") & "/" & Format(Now, "d") & "/" & Format(Now, "yy") & " " & Format(Now, "hAM/PM")
strbody = "Hello Team," & "<br><br>" & "Please update grids in the latest shared document within the folder below: <br><br>"
strbody4 = "<a href=""" & "\\abc.com\Shares\" & """>" & "\\ccx.abc.com\Shares\Teams\CSC\Staffing\Confidential\MSOC\DailyReports\" & "</a>"

strbody2 = "<br><br>" & "Thank you," & "<br>"
strbody3 = "<BODY STYLE=font-size:11pt;font-family:Calibri>"

On Error Resume Next

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

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

signature = OutMail.body

On Error Resume Next
With OutMail
.Display
.To = "test@google.com"
.CC = ""
.BCC = ""
.Subject = "Scrub Alert " & txtdate
.HTMLBody = strbody3 & strbody & strbody4 & RangetoHTML(rng) & strbody2 & signature
.Display 'or use .Send
End With

On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing

End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

mssbass

Active Member
Joined
Nov 14, 2002
Messages
252
Platform
  1. Windows
Figured it out. I removed the .Display after the .HTMLBody since it was already above and changed the .HTMLBody with the following:

.HTMLBody = strbody3 & strbody & strbody4 & RangetoHTML(rng) & strbody2 & signature &.HTMLBody
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,606
Messages
5,838,340
Members
430,538
Latest member
PedroOliveira

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
Top