我需要将Ajax AsyncFileUpload Control中的图像发送到邮件正文,而不将其保存到服务器文件夹。
我尝试过以下代码。 但邮件正文中的图像显示为“红叉标记”。
objMail.To.Add("me@abc.com");
objMail.From = new System.Net.Mail.MailAddress("abc@abc.com");
objMail.Subject = "Employee Introduction";
objMail.IsBodyHtml = true;
string Body = "";
Body ="I want to attach image here" + "<img src='cid:image1'>" + Environment.NewLine;
objMail.Body = Body;
AlternateView htmlview = default(AlternateView);
htmlview = AlternateView.CreateAlternateViewFromString(Body, null, "text/html");
LinkedResource imageResourceEs = new LinkedResource(AsyncFileUpload1.PostedFile.InputStream, "image/jpg");
imageResourceEs.ContentId = "image1";
imageResourceEs.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
htmlview.LinkedResources.Add(imageResourceEs);
objMail.AlternateViews.Add(htmlview);
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("abc.com");
smtp.Send(objMail);
任何人都可以帮我这样做吗? 提前谢谢。