need help to send email with background images and text with top of background?

Posted by Prabu_Spark under ASP.NET on 3/5/2014 | Points: 10 | Views : 734 | Status : [Member] | Replies : 0
Hi sir,
Tell me the steps to send email with background images and text with top of background. I tried the below code the text and background will appear separately. Kindly give me the solution for this problem.

Code:
*************



string path = Server.MapPath(@"images/prof_bg.jpg"); // my logo is placed in images folder

LinkedResource logo = new LinkedResource(path);
logo.ContentId = "companylogo";
// done HTML formatting in the next line to display my logo
AlternateView av1 = AlternateView.CreateAlternateViewFromString("<html><body background=cid:companylogo><br><h1></h1></body></html>"+"Hi this is J.Prabu", null, MediaTypeNames.Text.Html);
av1.LinkedResources.Add(logo);

MailMessage MyMailMessage = new MailMessage("someone@gmail.com", "welcome@gmail.com");


MyMailMessage.Subject = "Testing Mail";


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(@"images/prof_bg.jpg"), "image/jpeg");

imagelink.ContentId = "imageId";

imagelink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;

htmlView.LinkedResources.Add(imagelink);

MyMailMessage.AlternateViews.Add(htmlView);



MyMailMessage.IsBodyHtml = true;
NetworkCredential mailAuthentication = new NetworkCredential("someone@gmail.com", "123");
SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587);
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = mailAuthentication;
mailClient.EnableSsl = true;
mailClient.Send(MyMailMessage);

With regards,
J.Prabu.
[Email:prbspark@gmail.com]



Responses

(No response found.)

Login to post response