0
Answer

A little problem with sending an embeded picture in a mail

avi li

avi li

17y
1.7k
1
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
Next Recommended Forum