If I understand you correctly, you are using C# to create the text source of a multi-part html email but are unsure how to embed an image to use as a link.
If that's correct, I suggest you create such an email using a client such as Outlook or Thunderbird and view the source code to see how it's done. The image itself will be encoded (Base64/uuencode I think) so you'll have to figure that part out.
It sometimes works, sometimes doesn't... HOWEVER, most major mail systems BLOCK images in email... And newer email programs (Thunderbird 2x and up, for example) BLOCK images by default.
Normally, only external images are blocked. The reason for this is that the image url can include a recipient identifier so that it's possible to work out who has opened and read an email.
Some clients may also block embedded images since viruses have been spread in the past by exploiting faults in image rendering code, however I believe that most do not (but I could be wrong). It would certainly be wise to include "alt" text for the image in case the image is blocked.
Wow thanks for all the responses.
Yes I am using C# to create the text source based on info on the recipient’s name and location. Then my C# program sends the email to the recipient and CCs the salesman for the recipient’s location.
We currently have the same image, more like a icon, and link in the Outlook signature of most of our company emails and it seems to be going through. I have been studying those emails to figure out how this works. In looking at that source code the lines are long but there are line breaks of some sort, do I need them in my Html text? The link works I just can’t get it to show the image not the alt.
Below is the entire body for my current tests:
message.Body = "<html><body><p>The image, with link, should show below.</p><br><br> <p class=MsoNormal><a href=\"http://www.#*$!.com/blog\"><span style='color:windowtext;text-decoration:none'><img border=0 width=198 height=115 id=\"Picture_x0020_1\" src=\"cid:image001.jpg@01CB2371.B4BFDAE0\" alt=\"Blog Graphic -1\"></span></a><o:p></o:p></p></body></html>";
What does the ‘@01CB2371.B4BFDAE0’ do?
If you scroll down you'll find
I looked at the source code for an email with the graphic I am trying to duplicate and I could not find any other instance of some_random_but_identifying_string nor could I find the text ‘Content-ID:’.
Would it matter that is part of an Outlook signature? I notice that the name in the HTML source does not match what the original file name most likely was. Does Outlook somehow vett the graphic then store a vetted copy for attachment to emails?
Thanks again for the responses. I feel like I am so close but no cigar. Yet!
I've cut off the initial headers and most of the image but this is the source code of the quick test I tried ...
X-Envelope-To: ## deleted by Kaled ##
This is a multi-part message in MIME format.
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
_gggg_ <http:// ## deleted by Kaled ##>
Content-Type: text/html; charset=ISO-8859-1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<body bgcolor="#ffffff" text="#000000">
<a href="http:// ## deleted by Kaled ## "><img
src="cid:firstname.lastname@example.org" alt="" border="0"
........ etc. ........
Hope this helps,
Am I doing this the hard way?
If I am trying so hard to duplicate what Outlook is already doing should I just use Outlook with command line switches, OLE or some other ‘hook’ to send the emails?
The Outlook /c message class command line switch look promising I just need to figure out how to pass a message class object.