TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prabu Spark
NA
124
204.4k
need help to send email with background images and text?
Mar 5 2014 3:24 AM
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("
[email protected]
", "
[email protected]
");
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("
[email protected]
", "123");
SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587);
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = mailAuthentication;
mailClient.EnableSsl = true;
mailClient.Send(MyMailMessage);
Reply
Answers (
1
)
how to handle exception in C#?
Copying winforms from one application to another