Help with including Signature in VBA Macro

suunto

New Member
Joined
Jan 7, 2016
Messages
7
Hi All,

I'm attempting to include my default signature into an Outlook email that is created from a macro I have in a workbook. So far, I have code that can create an email, add the necessary recipients, add the necessary attachment, and add the necessary body to my email. However, the .Body part of the code overwrites everything in my email, including the default signature. Can anyone help me so that .Body part of my code does not overwrite the signature in my email? See code here:

Code:
Set apOutlook = CreateObject("Outlook.Application")apOutlook.Session.Logon
    


Set itEmail = apOutlook.CreateItem(olMailItem)


With itEmail
    .Display
    .To = Worksheets("Distribution List").Range("B2")
    .CC = Worksheets("Distribution List").Range("C2")
    .Subject = MonthName(Period) & Worksheets("Distribution List").Range("A2")
    .Attachments.Add ("C:\Users\Suunto\Desktop\Attachment.pdf")
    .Body = Worksheets("Distribution List").Range("D2")
End With






End Sub


Here is the issue as I see it: Once my mail item is created, I can see where my Outlook signature is included. However, once the code gets to the .Body part, it replaces the entire email (that is, the default signature) with the range in cell D2. I've tried changing
Code:
.Body = Worksheets("Distribution List").Range("D2")
to
Code:
.HTMLBody = Worksheets("Distribution List").Range("D2") & .HTMLBody

which does include the signature, but this also erases all formatting. Is there a way I can modify original coding to include default signature, and not affect formatting of the contents in .Range("D2")?

Thanks a bunch!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Thanks for this resource, I spent some time here and may have to return. I was hoping to be able to modify my current code, since it does 95% of what I need, just need that extra 5% in the signature. When I was on his website earlier, I could not see a way to modify my code, but rather rewrite and take his approach completely.
 
Upvote 0

Forum statistics

Threads
1,215,398
Messages
6,124,699
Members
449,180
Latest member
craigus51286

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