Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
526 views
in Technique[技术] by (71.8m points)

winforms - How to embed an image into an Outlook HTML email message?

We have a Winforms application which supports dragging and dropping chunks of HTML into Outlook (HTML) mail messages.

Chunks of text are fine.

But how do we proceed with images? Let's assume we don't want to host the images online but instead we want to send them with the email message. Assume also that we do want to see the image inline, not as an attachment (where the recipient's email client supports that, of course).

If you look at the HTML source of an Outlook message there are "cid" tags for images (which point to the image as an attachment I guess), but how do we go about generating a cid/contentid?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If a manual step in the process is an option, you can do it like this:

  1. create the HTML automatically or manually as a saved HTML file, with <img> tags that link to locally-saved image files
  2. attach the HTML to an Outlook email using the 'Insert as text' option tucked away under the down-arrow on the "Insert" button when selecting the HTML file as an attachment.

This populates the HTML email with the HTML from the file and embeds all images. I believe this tool uses Base64 encoding to embed the images as described in Sam's email.

Depending on the workflow, this method might be easier than converting images to Base64 yourself.

Note that this method only works in Outlook for Windows, not Outlook for Mac.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...