ru852
ru852

Reputation: 1

Add a non default signature in Outlook by VBA

There are many posts about how to add a default signature in drafting a new email in outlook by VBA.

However, is there any way to choose which signature to insert in the email? I am writing a VBA to copy data from excel and then draft a new email in outlook with non-default signature.

Many thanks!

Upvotes: 0

Views: 746

Answers (1)

Chris Meurer
Chris Meurer

Reputation: 468

In order to include a non-standard signature you would need to open the signature template from the %AppData%\Microsoft\Signatures folder, and append the contents of the appropriate file to your message body.

.... 'Your other code to create the mailitem "msg" goes here.'

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(Environ("AppData") & "\Microsoft\Signatures\mySig2.htm", ForReading)
strText = objTextFile.ReadAll
objTextFile.Close

msg.HTMLBody = msg.HTMLBody & strText

Upvotes: 1

Related Questions