I'm trying to send a message using the ASPX page and code c # when
the goal to incorporate a picture in a message similar to many sites on
the web.
The searched little on Google and found all kinds of code combinations
that should make the task ... actually i focused on the code listed
below . if i look at the email message received I can see the picture
as white square containing a red X indicates that the -HTML code is
supposed to contain image but not actually covered, so that the
displays the square.
I'd be happy if someone could raise the subordination and write the
code properly in - C # asp.net pages to send mail who can also
incorporate a photo .
I used a code:
Bash
protected void sendImg_Click(object sender, EventArgs e)
{
string strMailContent = "Welcome new user";
string fromAddress = "[email protected]";
string toAddress = "[email protected]";
string contentId = "image1";
string path = Server.MapPath(@"img/LogoWeb.jpg"); // my logo is placed in images folder
MailMessage mailMessage = new MailMessage(fromAddress, toAddress);
mailMessage.Subject = "Welcome new User";
LinkedResource logo = new LinkedResource(path);
logo.ContentId = "companylogo";
// done HTML formatting in the next line to display my logo
AlternateView av1 = AlternateView.CreateAlternateViewFromString("
" + strMailContent, null, MediaTypeNames.Text.Html);
av1.LinkedResources.Add(logo);
mailMessage.AlternateViews.Add(av1);
// mailMessage.AlternateViews.Add(imageView);
mailMessage.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient(); //use this if you are in the development server
smtp.Send(mailMessage);
}
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Devin21 reputationPosted Jun 19, 2009, 12:21 PM EDT
0
In the body of your message could you just do a where logo.jpg is a URL of your image. If the image is not web accessible then you will need to find another way.
Devin21 reputationPosted Jun 19, 2009, 12:21 PM EDT
where logo.jpg is a URL of your image. If the image is not web accessible then you will need to find another way.
Devin21 reputationPosted Jun 19, 2009, 12:22 PM EDT