实际上邮件(html模板)是从asp.net发送的,没有任何错误......但是html模板没有在邮件中查看......它只显示下载选项......
代码是..
string strMailContent = "Welcome new user";
string cid = "banner.jpg";
string path = Server.MapPath(@"images/banner.jpg"); // my logo is placed in images folder
MailMessage mailMessage = new MailMessage();
MailAddressCollection addcoll = new MailAddressCollection();
addcoll.Add("kollihari1209@gmail.com");
addcoll.Add("kollihari1209@gmail.com");
mailMessage.From = addcoll[0];
mailMessage.To.Add(addcoll[1]);
mailMessage.Subject = "Welcome new User";
LinkedResource logo = new LinkedResource(path);
logo.ContentId = "banner";
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();
mailSender.Host = "smtp.gmail.com";
mailSender.Port = 587;