Signature is not appearing in Email created via VBA

Oberon70

Board Regular
Joined
Jan 21, 2022
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have the below code, but the signature doesn't appear when I run it? Any idea why?

VBA Code:
Sub email()

Dim source_file, to_emails, cc_emails As String
Dim i, j As Integer
Dim strFile As String
Dim filelocation As String
Dim fCell As String
Dim OApp As Object, OMail As Object, signature As String


Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)


Set ws = Sheets("Report")


fCell = ActiveCell.Row

filelocation = Sheets("Report").Range("S" & fCell)

ws.Range("S" & fCell).Select

source_file = filelocation

'signature = OMail.Body

With OMail
    .Display
    .To = "TimeLord@Tardis.com"
    .Subject = "What Century
    .Attachments.Add source_file
    .Body = "Hi Doctor," & vbNewLine & vbNewLine & "Would you please let me know what time and place we are visiting?" & vbNewLine & vbNewLine & "Thanks"
    .Display
    '.Send
End With

Set OMail = Nothing
Set OApp = Nothing
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
you need to attach the signature before the body. So change would be something like (not sure if you would need to change to htmlbody rather than body)

VBA Code:
With OMail
    .Display
    signature = Omail.Body
    .To = "TimeLord@Tardis.com"
    .Subject = "What Century
    .Attachments.Add source_file
    .Body = "Hi Doctor," & vbNewLine & vbNewLine & "Would you please let me know what time and place we are visiting?" & vbNewLine & vbNewLine & "Thanks"
    .body = .body & signature
    .Display
    '.Send
End With
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,684
Members
449,116
Latest member
HypnoFant

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