Search code examples
htmlvbaoutlookhtml-email

Missing Image in Signature File



I'm working on a short script, where I generate mails based on a Access DB, using the Outlook.MailItem with htmlbody. Everything went fine, till it comes to the signature integration part at the very end of my mails. A handcrafted mail with signature embadding in Outlook looks fine, but the result of my code doesnt looks right. Finding the signature path isnt much of a big deel, but somehow the figure doesnt appeare as expected, and it prints a "image not found" message. I investigated the Signature .htm file in terms of the tag, but it seems ok to me.

Thanks for your help :)

Some code:

For Each oFile In oFolder.Files
        Dim filename As String
        filename = oFile.name
        If filename Like "*.htm" And Not filename Like "Teampostfach*" Then
            sig = oFile.OpenAsTextStream(1, 0).ReadAll
        End If
        Next oFile

...
outMail.HTMLBody = emailText & sig 

Solution

  • Firstly, concatenating two HTML documents won't produce a valid HTML document. The two need to be merged, and that includes styles as well as the HTML data itself.

    You also need to explicitly add signature images as attachments and modify the img tags appropriately to point to these image attachments.

    You can try to display the message first (Outlook will add the signature to the empty message), and then append your HTML message body.

    If using Redemption (I am its author) is an option, it exposes RDOSignature object and allows to insert any signature without displaying the message using RDOSignature.ApplyTo() method.