0
votes

I have set a macro in excel to create email need to have the Outlook signature line for the sender.

Tried .htmlbody= sig Signature = .htmlbody

Dim Email_Subject, Email_Send_To, _ Email_Body As String Dim Mail_Object, Mail_Single As Variant

    Email_Subject = Range("B7").Value
    Email_Send_To = Range("B9").Value
    Email_Body = Range("B8").Value

    On Error GoTo debugs
    Set Mail_Object = CreateObject("Outlook.Application")
    Set Mail_Single = Mail_Object.CreateItem(0)
    With Mail_Single
        .Subject = Email_Subject
        .To = Email_Send_To
        .Body = Email_Body
        .Display

    End With

I want to have the person that is sending the email default signature from outlook show at bottom of email.

1

1 Answers

0
votes

Be aware, the Body property of the MailItem class represents the message body in plain text. If you want to preserve any formatting you need to use the HTMLBody property.

With Mail_Single
        .Subject = Email_Subject
        .To = Email_Send_To
        .Body = Email_Body
        .Display
    End With

The signatures are being kept as separate files in the Signatures folder. You can find this folder in the following location:

  • Windows XP

C:\Documents and Settings\%username%\Application Data\Microsoft\Signatures

  • Windows Vista, Windows 7, Windows 8 and Windows 10

C:\Users\%username%\AppData\Roaming\Microsoft\Signatures

To see this folder you must have View hidden files and folders enabled or you can simply copy and paste the above paths in the address bar in Explorer to directly open the folder.

There are three main ways for working with bodies in Outlook:

  1. Body.
  2. HTMLBody.
  3. Word editor. The Inspector class provides the WordEditor property which returns an instance of the Document class from the Word object model which represents the message body. Outlook uses Word as an email editor.

You can read more about that in the Chapter 17: Working with Item Bodies.

I want to have the person that is sending the email default signature from outlook show at bottom of email.

Basically, you just need to insert the signature before the closing <body> tag and set the HTMLBody property to the result HTML markup.