{"id":12162,"date":"2012-10-11T16:00:45","date_gmt":"2012-10-11T16:00:45","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/?p=2442"},"modified":"2022-08-12T11:32:13","modified_gmt":"2022-08-12T11:32:13","slug":"insert-outlook-signature-in-email","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2012\/10\/insert-outlook-signature-in-email\/","title":{"rendered":"How to insert Outlook Signature in Email by Excel VBA"},"content":{"rendered":"

In this Article you are going to learn how to insert Outlook Signature in outlook email while sending an email via Excel VBA. It means while sending an email from Outlook via Excel Macro, if you want already saved signature to be inserted at the end of your email, then here is the code to do so.
\n 
\n<< Return to Send Email Tutorial Page<\/strong><\/a>
\n <\/p>\n\n\n\n
\n 
\nImportant:<\/strong>
\n \n<\/td>\n<\/tr>\n
\nAs soon as you create a signature in Outlook it saves the signature in 3 different types of files: .HTM, TXT and RTF<\/strong> as shown below:
\n<\/p>\n

These files get stored at the following location in your system:
\n 
\nWindows XP :<\/strong>
\nC:\\Documents and Settings\\Vish\\Application Data\\Microsoft\\Signatures
\n <\/p>\n

Windows 7 and 8 :<\/strong>
\nC:\\Users\\Vish\\AppData\\Roaming\\Microsoft\\Signatures<\/p>\n

\n<\/td>\n<\/tr>\n<\/table>\n

Note: <\/strong>
In the below code when we are creating an email in Outlook then at the end of the email, we will insert the Signature from the .txt<\/strong> file or .htm<\/strong> file.
\n<\/p>\n

\"Signature\"

Signature<\/p><\/div>\n

 <\/p>\n

In the below code we are first checking if these files exists and have some values in it. If yes then we are reading the text from the signature file and inserting that signature in the email.
\nThus we need a function which read and return the Signature Texts from the file wherever we need to insert it in the body of the Outlook email.<\/p>\n

\nFunction to read the Signature file and return the Signature Text<\/strong><\/p>\n

\n\nFunction GetSignature(fPath As String) As String\n    Dim fso As Object\n    Dim TSet As Object\n    Set fso = CreateObject(\"Scripting.FileSystemObject\")\n    Set TSet = fso.GetFile(fPath).OpenAsTextStream(1, -2)\n    GetSignature= TSet.readall\n    TSet.Close\nEnd Function\n\n<\/code><\/pre>\n

<\/p>\n

Below is the code to create the Outlook Email with the Signature at the end.
\nHere there could be two types of Email and Signatures:<\/p>\n