c# - 需要删除通过 asp.net 发送的电子邮件中的附件
问题描述
我编写了一个代码来通过 asp.net 在邮件中发送内联图像。
我在电子邮件中获取图像,但此外,我还获取 .bin 格式的图像附件。
我怎样才能摆脱这个附件?
此附件出现在所有电子邮件程序(mobile、owa、microsoft outlook 2016)中
附件名称为 AT00001.bin
下面是代码
protected void UBR_HNC_Click(object sender, EventArgs e)
{
SmtpClient smtpClnt;
MailMessage objMail;
// Prepare Email
// Load Email Template from HTML File.
//String sHTMLbody = string.Empty;
// Send Email
// Create new Mail Object
objMail = new MailMessage(); // Create new Mail Object
objMail.From = new MailAddress("santoshkumar_g@abc.com");
objMail.To.Add(new MailAddress("santoshkumar_g@abc.com"));
objMail.Subject = "UBR Delivery HNC";
objMail.AlternateViews.Add(Mail_Body());
objMail.IsBodyHtml = true;
// Open SMTP Connection to Mail Server and send email.
smtpClnt = new SmtpClient();
smtpClnt.Host = "10.98.134.29";
smtpClnt.Port = Convert.ToInt16("25");
smtpClnt.EnableSsl = false;
smtpClnt.UseDefaultCredentials = false;
smtpClnt.Send(objMail);
smtpClnt.Dispose(); // Close the SMTP Mail server connection.
objMail.Dispose(); // Clear the mail object
}
private AlternateView Mail_Body()
{
LinkedResource imageResource = new LinkedResource(Server.MapPath("~/images/UBR_Delivery_L2_HNCmail.png"));
imageResource.ContentId = "HDIImage";
string str = @"
<tr>
<td>
<image src=cid:HDIImage id='img' alt=''/>
</td>
</tr>
";
AlternateView AV =
AlternateView.CreateAlternateViewFromString(str, null, MediaTypeNames.Text.Html);
AV.LinkedResources.Add(imageResource);
return AV;
}
解决方案
推荐阅读
- php - 所有链接中的奇怪 WordPress index.php
- java - docker容器中的Java服务未连接到主机mysql
- docker - Docker 容器未连接到服务器上的另一个 Docker 容器
- r - 停止执行但不将输出生成为 R 中的“错误”
- python - 在 JupyterHub 中与 Bokeh 服务器交互
- reactjs - 使用 redux thunk 从 Axios 获取响应数据
- c++ - BOOST_CLASS_EXPORT 语法错误
- python - 在 Python 环境中自动运行代码生成工具(例如 thrift)的最佳实践
- asp.net-core - 将视频流重定向到视频播放器(如 HTML5 视频播放器)的最佳方法
- redirect - 将我的博客设为主页?重定向?