本文介绍了为什么通过带有C#的asp.net在邮件发送过程中,Outlook中没有显示图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我无法通过asp.net使用c#2.0 / c#1.1发送邮件时查看图像。我的代码如下: string strMailContent = 欢迎新用户; string fromAddress = alexander.junior @ nestgroup.net; string toAddress = alexander.junior @ nestgroup.net; string contentId = image1; string path = Server.MapPath( @ 图片/ welfare.jpg); // 我的徽标位于图像文件夹中 MailMessage mailMessage = new MailMessage(fromAddress,toAddress); mailMessage.Bcc.Add( [email protected]); // 将您的ID放在此处 mailMessage.Subject = 欢迎新用户; LinkedResource logo = new LinkedResource(path); logo.ContentId = companylogo; // 在下一行完成HTML格式以显示我的徽标 AlternateView av1 = AlternateView.CreateAlternateViewFromString( < html>< body>< img src = cid:companylogo /> < br>< / body>< / html> + strMailContent, null ,MediaTypeNames.Text.Html); av1.LinkedResources.Add(logo); mailMessage.AlternateViews.Add(av1); mailMessage.IsBodyHtml = true ; SmtpClient mailSender = new SmtpClient( mail .nestgroup.net); // 如果您在开发服务器中,请使用此 mailSender.Send(mailMessage); 解决方案 I am unable to view the Image on sending mail via asp.net with c# 2.0/c# 1.1. My code as follows:string strMailContent = "Welcome new user";string fromAddress = "[email protected]";string toAddress = "[email protected]";string contentId = "image1";string path = Server.MapPath(@"Images/welfare.jpg"); // my logo is placed in images folderMailMessage mailMessage = new MailMessage(fromAddress, toAddress);mailMessage.Bcc.Add("[email protected]"); // put your id heremailMessage.Subject = "Welcome new User";LinkedResource logo = new LinkedResource(path);logo.ContentId = "companylogo";// done HTML formatting in the next line to display my logoAlternateView av1 = AlternateView.CreateAlternateViewFromString("<html><body><img src=cid:companylogo/><br></body></html>" + strMailContent, null, MediaTypeNames.Text.Html);av1.LinkedResources.Add(logo);mailMessage.AlternateViews.Add(av1);mailMessage.IsBodyHtml = true;SmtpClient mailSender = new SmtpClient("mail.nestgroup.net"); //use this if you are in the development servermailSender.Send(mailMessage); 解决方案 这篇关于为什么通过带有C#的asp.net在邮件发送过程中,Outlook中没有显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 20:25