Function 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\nEmail and Signature with Simple Text<\/li>\n Email and Signature with the HTML<\/li>\n<\/ul>\n<\/strong> \nWe will see the code of both the above methods below one by one:<\/p>\n
<\/p>\n
Email and Signature with Simple Text<\/h2>\n <\/p>\n
\nSub With_Text_Signature()\n\n 'Do not forget to change the email ID\n 'before running this code\n\n Dim OlApp As Object\n Dim NewMail As Object\n Dim EmailBody As String\n Dim StrSignature As String\n Dim sPath As String\n\n Set OlApp = CreateObject(\"Outlook.Application\")\n Set NewMail = OutApp.CreateItem(0)\n\n EmailBody = \"Type the Body of your email\"\n\n '*****************************************************\n ' Important\n '*****************************************************\n ' go to the appdata path as mentioned in\n ' the above important point. Check the name of\n ' the signature file. For example: here in my system\n ' the signature's file name is vish.txt, vish.htm\n ' Therefore before running this code, check the\n ' name fo the signature file in your system and\n ' replace vish.txt with your file name.\n '****************************************************\n\n sPath = Environ(\"appdata\") & \"\\Microsoft\\Signatures\\vish.txt\"\n\n ' If the path and file name given by you is not\n ' correct then code you insert a blank Signature\n \n If Dir(sPath) <> \"\" Then\n StrSignature = GetSignature(sPath)\n Else\n StrSignature = \"\"\n End If\n\n On Error Resume Next\n With NewMail\n .To = \"info@learnexcelmacro.com\"\n .CC = \"info@learnexcelmacro.com\"\n .BCC = \"info@learnexcelmacro.com\"\n .Subject = \"Type your Subject here\"\n ' Here at the end of the Email Body\n ' Text Signature is inserted.\n .Body = EmailBody & vbNewLine & vbNewLine & StrSignature\n .send\n End With\n On Error GoTo 0\n Set NeMail = Nothing\n Set OlApp = Nothing\nEnd Sub\n<\/code><\/pre>\n<\/p>\n
Email and Signature with HTML Body and HTML Signature<\/h2>\n <\/p>\n
\nSub With_HTML_Signature()\n\n 'Do not forget to change the email ID\n 'before running this code\n\n Dim OlApp As Object\n Dim NewMail As Object\n Dim EmailBody As String\n Dim StrSignature As String\n Dim sPath As String\n\n Set OlApp = CreateObject(\"Outlook.Application\")\n Set NewMail = OlApp.CreateItem(0)\n \n ' Here Since we are talking about\n ' the HTML email then we need to\n ' write the Body of the Email in\n ' HTML.\n\n EmailBody = \"Hello Friends !!\" & \" Welcome to LearnExcelMacro.com\" & vbNewLine & _\n \"Here i will make you awesome in Excel Macro. You can mail me at info@learnexcelmacro.com\"\n\n '*****************************************************\n ' Important\n '*****************************************************\n ' go to the appdata path as mentioned in\n ' the above important point. Check the name of\n ' the signature file. For example: here in my system\n ' the signature's file name is vish.txt, vish.htm\n ' Therefore before running this code, check the\n ' name of the signature file in your system and\n ' replace vish.txt with your file name.\n '****************************************************\n\n sPath = Environ(\"appdata\") & \"\\Microsoft\\Signatures\\vish.htm\"\n\n ' If the path and file name given by you is not\n ' correct then code you insert a blank Signature\n \n If Dir(sPath) <> \"\" Then\n StrSignature = GetSignature(sPath)\n Else\n StrSignature = \"\"\n End If\n\n On Error Resume Next\n With NewMail\n .To = \"info@learnexcelmacro.com\"\n .CC = \"info@learnexcelmacro.com\"\n .BCC = \"info@learnexcelmacro.com\"\n .Subject = \"Type your Subject here\"\n ' Here at the end of the Email Body\n ' HTML Signature is inserted.\n .htmlBody = EmailBody & \" \" & StrSignature\n .send\n End With\n On Error GoTo 0\n Set NeMail = Nothing\n Set OlApp = Nothing\nEnd Sub\n\n<\/code><\/pre>\n<\/p>\n
Important : Outlook Signature with an Image<\/h2>\n If your signature contains some image, then above method will not display the image in signature. You will see that all the texts are displayed in signature but not the image. <\/p>\n
To overcome this issue, there are two solutions.. refer to my new article<\/a><\/p>\n<\/span>","protected":false},"excerpt":{"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 […]<\/p>\n","protected":false},"author":45,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[5205,1676],"tags":[],"class_list":["post-12162","post","type-post","status-publish","format-standard","hentry","category-send-email","category-excel-tips"],"yoast_head":"\n
How to insert Outlook Signature in Email by Excel VBA - Let's excel in Excel<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n