Implememtation:
try
{
MailMessage mail = new MailMessage();
mail.To.Add("xxx@gmail.com");
mail.From = new
MailAddress("xxxx@gmail.com");
mail.Subject = "Test with Image";
string Body = "<b>Welcome to
popfly!!</b><br><img alt=\"\" hspace=0 src=\"cid:imageId\"
align=baseline border=0 >";
AlternateView htmlView =
AlternateView.CreateAlternateViewFromString(Body, null, "text/html");
LinkedResource imagelink = new
LinkedResource(Server.MapPath(".") + @"\popfly.JPG", "image/jpeg");
imagelink.ContentId = "imageId";
imagelink.TransferEncoding =
System.Net.Mime.TransferEncoding.Base64;
htmlView.LinkedResources.Add(imagelink);
mail.AlternateViews.Add(htmlView);
SmtpClient smtp = new SmtpClient();
smtp.DeliveryMethod =
SmtpDeliveryMethod.PickupDirectoryFromIis;
smtp.Send(mail);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
OUTPUT:
|