问题描述
我写了一个下面的代码来发送带有“LinkedResource”的邮件。它按照我们的要求工作正常,但没有显示正文消息。请检查下面的代码并告知为什么没有显示正文消息。
private void MailSend()
{
MailMessage Mail = new MailMessage();
Mail.From = new MailAddress("edp.kharind@khindia.com");
Mail.To.Add("edp.kharind@khindia.com");
Mail.Subject = "This is Image Test.";
Mail.Body = "This is the body of the email45454545";
LinkedResource LinkedImage = new LinkedResource(@"D:\GatePass.JPG");
LinkedImage.ContentId = "MyPic";
//Added the patch for Thunderbird as suggested by Jorge
LinkedImage.ContentType = new ContentType(MediaTypeNames.Image.Jpeg);
AlternateView htmlView = AlternateView.CreatealternateViewFromString(
"You should see image next to this line. <img src=cid:MyPic>",null,"text/html");
htmlView.LinkedResources.Add(LinkedImage);
Mail.AlternateViews.Add(htmlView);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
SmtpClient smtp = new SmtpClient("smtp.office365.com",587);
try
{
//smtp.Send(Mail);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = true;
smtp.Credentials = new System.Net.NetworkCredential("edp.kharind@khindia.com","xyz");
smtp.TargetName = "STARTTLS/smtp.office365.com";
smtp.Send(Mail);
}
catch (SmtpException ex)
{
//Logger.LogException(ex);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)