<\/a><\/p>\nNote: <\/strong>In HTML, if the files are within the same folder where your HTML file is then you do not need to provide the complete path, rather you just give the folder name and file name. HTML by default look for that folder and image within the same directory. This is how outlook reads it and displays the images in mails. \nBut when we read it from HTML via VBA then this image URL becomes unknown for outlook to display the image in Signature. I hope you understood the problem.<\/p>\nNow you know the problem, then solution is simple :<\/p>\n
Solution<\/h1>\n Before we use the HTML code for signature at the end of Mail body, we need to change all the path (incomplete URLs) with complete URLs.<\/p>\n
Read my comments in the code where I have made the changes.<\/p>\n
Method 1: Any Outlook Signature with Image<\/h1>\n\r\nSub With_HTML_Signature_With_Image()\r\n\r\n 'Do not forget to change the email ID\r\n 'before running this code\r\n\r\n Dim OlApp As Object\r\n Dim NewMail As Object\r\n Dim EmailBody As String\r\n Dim StrSignature As String\r\n Dim sPath As String\r\n Dim signImageFolderName As String\r\n Dim completeFolderPath As String\r\n\r\n Set OlApp = CreateObject("Outlook.Application")\r\n Set NewMail = OlApp.CreateItem(0)\r\n \r\n ' Here Since we are talking about\r\n ' the HTML email then we need to\r\n ' write the Body of the Email in\r\n ' HTML.\r\n\r\n EmailBody = "Hello Friends !!" & "\r\n\r\nWelcome to LearnExcelMacro.com" & vbNewLine & _\r\n "Here i will make you awesome in Excel Macro.\r\n\r\nYou can mail me at info@learnexcelmacro.com"\r\n\r\n '*****************************************************\r\n ' Important\r\n '*****************************************************\r\n ' go to the appdata path as mentioned in\r\n ' the above important point. Check the name of\r\n ' the signature file. For example: here in my system\r\n ' the signature's file name is vish.txt, vish.htm\r\n ' Therefore before running this code, check the\r\n ' name of the signature file in your system and\r\n ' replace vish.txt with your file name.\r\n '****************************************************\r\n\r\n sPath = Environ("appdata") & "\\Microsoft\\Signatures\\Default.htm"\r\n ' Files folder name is always same name as html file name appended by\r\n ' "_files"\r\n signImageFolderName = "Default_files"\r\n ' in outlook HTML forward slashes are used for\r\n ' the file path\r\n completeFolderPath = Environ("appdata") & "\\Microsoft\\Signatures\\" & signImageFolderName\r\n\r\n ' If the path and file name given by you is not\r\n ' correct then code you insert a blank Signature\r\n \r\n If Dir(sPath) <> "" Then\r\n StrSignature = GetSignature(sPath)\r\n ' Now replace this incomplete file path\r\n ' with complete path wherever it is used\r\n StrSignature = VBA.Replace(StrSignature, signImageFolderName, completeFolderPath)\r\n Else\r\n StrSignature = ""\r\n End If\r\n\r\n On Error Resume Next\r\n With NewMail\r\n .To = "info@learnexcelmacro.com"\r\n .CC = "info@learnexcelmacro.com"\r\n .BCC = "info@learnexcelmacro.com"\r\n .Subject = "Type your Subject here"\r\n ' Here at the end of the Email Body\r\n ' HTML Signature is inserted.\r\n .htmlBody = EmailBody & StrSignature\r\n .display\r\n .send\r\n End With\r\n On Error GoTo 0\r\n Set NeMail = Nothing\r\n Set OlApp = Nothing\r\nEnd Sub\r\n\r\n<\/code><\/pre>\nImportant : Do not Forget<\/h1>\n Do not forget to copy paste the below function in your module \nFunction to read the Signature file and return the Signature Text<\/strong><\/p>\n\r\nFunction GetSignature(fPath As String) As String\r\n Dim fso As Object\r\n Dim TSet As Object\r\n Set fso = CreateObject("Scripting.FileSystemObject")\r\n Set TSet = fso.GetFile(fPath).OpenAsTextStream(1, -2)\r\n GetSignature= TSet.readall\r\n TSet.Close\r\nEnd Function\r\n\r\n<\/code><\/pre>\nMethod 2 : Simple and Easy Trick (Only for Default Signature)<\/h1>\n All you need to do is, in your VBA code, before you assign a Body of your email, display it once on the screen. As soon as VBA displays the mail on screen, outlook, by default, adds its default signature at the end of the body of your email.<\/p>\n
Every time before sending the email, if you display your mail, you can see this method will be slow. Therefore it is not good for sending bulk emails in a loop. By the way this method, can be used for all type of signatures (Text, HTML, image etc.). But important to note than this is applicable for Default Signature in outlook only<\/strong><\/p>\nImportant<\/strong> .Display statement should be used anywhere but before the Email Body statement as explained above. If you display your email after putting the email body, then outlook will not append the default signature at the end of your email body.<\/p>\n\r\nSub Outlook_Default_Signature_With_Image()\r\n\r\n 'Do not forget to change the email ID\r\n 'before running this code\r\n\r\n Dim OlApp As Object\r\n Dim NewMail As Object\r\n Dim EmailBody As String\r\n Dim StrSignature As String\r\n Dim sPath As String\r\n\r\n Set OlApp = CreateObject("Outlook.Application")\r\n Set NewMail = OlApp.CreateItem(0)\r\n \r\n ' Here Since we are talking about\r\n ' the HTML email then we need to\r\n ' write the Body of the Email in\r\n ' HTML.\r\n\r\n EmailBody = "Hello Friends !!" & "\r\n\r\nWelcome to LearnExcelMacro.com" & vbNewLine & _\r\n "Here i will make you awesome in Excel Macro.\r\n\r\nYou can mail me at info@learnexcelmacro.com"\r\n\r\n On Error Resume Next\r\n With NewMail\r\n .To = "info@learnexcelmacro.com"\r\n .CC = "info@learnexcelmacro.com"\r\n .BCC = "info@learnexcelmacro.com"\r\n .Subject = "Type your Subject here"\r\n ' Important! Before writing the body of your email\r\n ' you should display the mail\r\n .display\r\n ' Here at the end of the Email Body\r\n ' HTML Signature is inserted.\r\n .htmlBody = EmailBody\r\n .send\r\n End With\r\n On Error GoTo 0\r\n Set NeMail = Nothing\r\n Set OlApp = Nothing\r\nEnd Sub\r\n\r\n<\/code><\/pre>\n<\/span>","protected":false},"excerpt":{"rendered":"Dear Friends, I was keep getting this question from many of you that whenever your outlook signature has an Image then rest of the texts are displayed correctly but Image was never displayed. It was always appearing with a red cross sign (missing image) image. In order to get rid of this problem there are […]<\/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-4918","post","type-post","status-publish","format-standard","hentry","category-send-email","category-excel-tips"],"yoast_head":"\n
Signature Image Appearing as Red Cross in Email Sent by Excel VBA<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n