需要帮助发送带有背景图像的背景图像和文本的电子邮件? [英] need help to send email with background images and text with top of background?
本文介绍了需要帮助发送带有背景图像的背景图像和文本的电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨先生,
请告诉我发送背景图片和文字的电子邮件的步骤。我尝试了下面的代码,文本和背景分开出现。请给我这个问题的解决方案。
代码:
字符串path = Server.MapPath(@images / prof_bg.jpg); //我的徽标放在图像文件夹中
LinkedResource logo = new LinkedResource(path);
logo.ContentId =companylogo;
//在下一行完成HTML格式以显示我的徽标
AlternateView av1 = AlternateView.CreateAlternateViewFromString(< html>< body background = cid:companylogo>< br>< h1> < / h1>< / body>< / html>+嗨这是J.Prabu,null,MediaTypeNames.Text.Html);
av1.LinkedResources.Add(logo);
MailMessage MyMailMessage = new MailMessage(someone@gmail.com,welcome@gmail.com);
MyMailMessage.Subject =测试邮件;
string Body =欢迎来到popfly !! < 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);
解决方案
嘿 Prabu ,
首先 您 可以 创建 HTML file in 图像 和 文本 我们的 拥有 选择 inserted , now you 追加 此 < span class =code-leadattribute> file body 您的 电子邮件跨度>。
我 已 已创建<在&span> class =code-leadattribute>相同,你 检查 他们 这里:
http: // www.c-sharpcorner.com/UploadFile/ cd7c2e / send-bulk-mails-using-smtp-configuration-part-2 /
http: // www.c-sharpcorner.com/UploadFile/cd7c2e/send-bulk-email-from-yahoo-and-hotmail-using- Asp-Net /
代码available top 这些 文章。
Hi Sir,
Please 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 appears 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 = "Welcome to popfly!!<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);
解决方案
Hey Prabu, Firstly You can create a HTML file in which Image and Text of our own choice can be inserted, now you can append this file in the body of your Email. I had created Articles on the same, you can check them here: http://www.c-sharpcorner.com/UploadFile/cd7c2e/send-bulk-mails-using-smtp-configuration-part-2/ http://www.c-sharpcorner.com/UploadFile/cd7c2e/send-bulk-email-from-yahoo-and-hotmail-using-Asp-Net/ Codes are also available at the top of these Articles.
这篇关于需要帮助发送带有背景图像的背景图像和文本的电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文