0

I have a Win Form application that does some boring accounting stuff and then sends it's data to some lucky recipients. I am using the Outlook 12.0 Interop objects and my applications environment ranges from office 2003 on XP to office 2007 on Win 7.

My issue lies with sending the corporate signature with the sent emails. It contains two images and I would like to embed these images so they appear to be part of the body (assuming the receiving mail client supports that).

I have tried a few different methods of accomplishing this; but still no luck!

I have tried:

  • Extracting the html data from the signatures folder, changing the html img tags src attribute to include 'file///'. This causes Outlook to replace the 'file///' with 'CID' and I assumed it would also embed the image... we should never assume :|. This is the method I found worked best for getting the rest of the signature.

  • (After creating a new MailItem) - Grabbing the HTMLBody of the MailItem and extracting the relevant part including the signature... This didnt work due to the new MailItem object being very inconsistent with it's signature. By that I mean sometimes the new item would include the signature and sometimes it wouldn't! :s I cannot figure out why it is not always there, no other part of my code has changed!

I read on another post here about the GetInspector property... Apparently just calling this will do 'Some stuff' and the signature will magically appear in your mail item... NO!

Things I can't do:

  • I cannot (as much as i would like to) shove the images online somewhere and point to them in the emails html.
  • I cannot use SMTP(It has to be through Outlook... sigh).

I am thinking that the best way seems to be my original method of messing about with the CID, but I do not really know much about what Outlook is doing in the background so I am having trouble figuring out what else I need to do to get the images sent along with the email.

Hoping someone out there has some idea about what I am doing wrong or what else I could try.

Please let me know if code would be helpful and I will post, (Most of the code tried is from this site... I just cannot find the links again and am trying to avoid making this question tooooo long).

Many thanks

Jammerz858
  • 1,605
  • 3
  • 14
  • 14
  • 1
    Perhaps this question might help: http://stackoverflow.com/questions/4196160/vsto-outlook-embed-image-mailitem – Bridge Nov 08 '12 at 17:28

1 Answers1

1

This is not the most efficient or flexible solution you can use, but probably the most robust and portable. You can convert your image bitmap into plain HTML and embed that HTML in your e-mail signature.

The conversion is quite simple, you can use the utility I wrote (open source) here.

onon15
  • 3,620
  • 1
  • 18
  • 22
  • Exchange actually prevents this and embedds the image as actual text (base64), and the client gets a massive footer in their email, let alone it gets treated as spam. Besides, what the poster wants is far beyond that simple. There is no simple way, and even with embedded VBA code in the exchange, every users needs admin rights to modify their registry settings. MS Exchange is a beast! – Fandango68 Aug 20 '13 at 06:11
  • Can you please elaborate what you think exchange does? I haven't seen any problems with embedding the "plain html" image. Exchange doesn't even know it used to be an image, as it's just a `` with colored cells. Checked my code on several outlook versions.
    – onon15 Aug 20 '13 at 06:26