如何使用电子邮件发送图像 [英] How to send image with email

查看:92
本文介绍了如何使用电子邮件发送图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的appData文件夹中有一个txt文件,我想在电子邮件中嵌入图片。





我的c#code



使用(StreamReader reader = File.OpenText(Server.MapPath(〜/ App_Data / RoomReservation.docx)))
{
MailMessage msg = new MailMessage();
string strMailContent =欢迎消息;;
msg.Subject =书房的查询;
msg.IsBodyHtml = true;
msg.To.Add(new MailAddress( admin@demo.com));
msg.Body = reader.ReadToEnd();
string imagePath = Server.MapPath(@〜/ images / eaderLogo.jpg);
//msg.Body=msg.Body.Replace(\"<%徽标%> ,imagePath);
msg.Body = msg.Body.Replace(<%日期%> ,txtArrivalDate.Text);
msg.Body = msg.Body.Replace(<% Room %> ,ddlNoofRoom.SelectedValue);
msg.Body = msg.Body.Replace(<%电子邮件%> ,txtEmailId.Text);
msg.Body = msg.Body.Replace(<% CustomerName %> ,txtContactPerName。文字);



msg.Priority = MailPriority.High;

SmtpClient myClient = new SmtpClient();

myClient.EnableSsl = false;

}



我的凭证保存在webconfig文件中











我这样的.txt文件



 <   p    样式  =  text-align:center >  <%徽标%>  <   / p  >  
< br >
Mr./Mis < b > <% CustomerName %> < b / >
< br / > < br / >
在演示酒店寻找< b > <%日期%> < b / > ,用于< b > <%会议室%> < b / > 房间,
< br / > < br / > 来自< b > <%电子邮件%> < b / > < br >
我们期待您的贡献。
< br < span class =code-keyword> /
> < br / >
演示酒店团队









请告诉我如何使用此代码嵌入图像

解决方案

您好Ashok,





试试这个链接 [ ^ ]

链接 [ ^ ]

我希望这可以帮到你。



问候,

RK


你需要使用LinkedResource类



使用ASP.NET在电子邮件中嵌入图像 [ ^ ]

i have a txt file in my appData folder and i want to embed images in emails.


my c# code

using (StreamReader reader = File.OpenText(Server.MapPath("~/App_Data/RoomReservation.docx")))
       {
           MailMessage msg = new MailMessage();
           string strMailContent = "Welcome Message;;
           msg.Subject = "Enquery for book room";
           msg.IsBodyHtml = true;
           msg.To.Add(new MailAddress("admin@demo.com"));
           msg.Body = reader.ReadToEnd();
           string imagePath =Server.MapPath(@"~/images/eaderLogo.jpg");
           //msg.Body=msg.Body.Replace("<%Logo%>",imagePath);
           msg.Body = msg.Body.Replace("<% Date%>", txtArrivalDate.Text);
           msg.Body = msg.Body.Replace("<% Room%>", ddlNoofRoom.SelectedValue);
           msg.Body = msg.Body.Replace("<% Email%>", txtEmailId.Text);
           msg.Body = msg.Body.Replace("<% CustomerName %>", txtContactPerName.Text);


msg.Priority = MailPriority.High;
SmtpClient myClient = new SmtpClient();
myClient.EnableSsl = false;
}

my credential is save in webconfig file





my .txt file like this

<p style="text-align:center"><%Logo%> </p>
<br>
Mr./Mis <b> <% CustomerName %><b/>,
<br /><br />
Looking for Book room at demo Hotel for  <b><% Date%><b/>, for  <b><% Room%><b/> rooms,
<br /><br/> From <b><% Email%><b/><br>
We look forward to your contributions.
<br /><br />
The Demo Hotel Team





please tell me how i can embed image with this code

解决方案

Hi Ashok,


Try this link[^]
and this link[^]
I hope this would help you out.

Regards,
RK


You need to use LinkedResource class for that

Embed an Image in Email using ASP.NET[^]


这篇关于如何使用电子邮件发送图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆