How To Add Signature In Outlook Using Excel Vba

How to Add Signature in Outlook using Excel VBA – Answer

To add a signature in Outlook using Excel VBA, you can follow the steps below:

  1. Create a new Outlook MailItem object:
  2.       Dim olApp As Object
    Dim olMail As Object
    
    Set olApp = CreateObject("Outlook.Application")
    Set olMail = olApp.CreateItem(0)
        
  3. Set the email properties:
  4.       With olMail
      .Subject = "Your email subject"
      .Body = "Your email body text"
      ' Add other email properties as needed
    End With
        
  5. Create an HTML Signature template:
  6.       Dim signature As String
          
    signature = "Your HTML signature template here"
        
  7. Insert the signature into the email body:
  8.       With olMail
      .HTMLBody = .HTMLBody & signature
    End With
        
  9. Display the email for review:
  10.       olMail.Display
        
  11. Release the Outlook objects:
  12.       Set olMail = Nothing
    Set olApp = Nothing
        

In the code example above, you can replace “Your email subject” and “Your email body text” with the actual subject and body of your email. Additionally, you need to replace “Your HTML signature template here” with the actual HTML content of your signature.

Leave a comment