avi li

avi li

  • NA
  • 1
  • 0

A little problem with sending an embeded picture in a mail

Jul 5 2007 7:20 AM
Hi

I'm trying to send an HTML file that I created in Word. (I wrote some text in the Word file and then dragged a picture to the file in a certain place in the file and then saved it as HTML filtered).

Now, when I try to send the Word file through the File.ReadAllText method, the mail arrives without the picture in the body of the mail but only a blank box.

I used the LinkedResource of the AlternateView class as shown below but now the text of the mail doesn't appear.

Here is the code:
MailMessage MyMailMessage = new MailMessage();
Message.From = new MailAddress("myEmail");
Message.To.Add("DestinationEmail");
Message.Subject = "test";

AlternateView HTMLView = AlternateView.CreateAlternateViewFromString("<img src=cid:SampleEmbedImage>", null, "text/html");
LinkedResource MySampleEmbedImage = new LinkedResource("C:\\Pictures\\Pic1.jpg");
MySampleEmbedImage.ContentId = "SampleEmbedImage";
HTMLView.LinkedResources.Add(MySampleEmbedImage);
Message.AlternateViews.Add(HTMLView);
SmtpClient smtp = new SmtpClient("mail.MyMailServer.com");
smtp.Send(Message);


This causes the mail to arrive but with the picture in the top of the mail and with NO text at all.
What do I have to do to include the text of the mail in the file along with the picture that will appear in the right place inside the mail?


Thanks for any help

Go OT