0
您好,我想从Asp.net发送图像邮件。不是SiteMap中的有效虚拟路径
我有这样的错误::'http://domain-name.com/slideshow/original/Jellyfish.png'不是一个有效的虚拟路径。
我的代码是:
try
{
string _SenderEmailID = ReciverEmailID.Text.ToString();
string _ReciverEmailID = ReciverEmailID.Text.ToString();
string _Sender = FullName.Text.ToString();
string post = "JellyBeans.png";
string ImagePath = "http://www.domain-name.com/slideshow/original/";
string iImage = ImagePath + post;
img1.ImageUrl = ImagePath;
MailMessage mail = new MailMessage();
mail.To.Add(_ReciverEmailID);
mail.From = new MailAddress(_SenderEmailID);
mail.Subject = _Sender + " sent you a mail from 'www.domain-name.com";
string Body = "<img alt=\"\" hspace=0 src=\"cid:imageId\" align=baseline border=0 >";
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Body, null, "text/html");
LinkedResource imagelink = new LinkedResource(Server.MapPath(ImagePath)+ @post, "image/png");
imagelink.ContentId = "imageId";
imagelink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
htmlView.LinkedResources.Add(imagelink);
mail.AlternateViews.Add(htmlView);
SmtpClient smtp = new SmtpClient();
smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smtp.Send(mail);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
当我从LinkedResource中删除Server.MapPath imagelink = new LinkedResource(iImage,“image/png”); 现在我面临新的错误:URI格式不支持,而。 @Sam Leach – 2013-04-26 12:35:38
你可以把图像放到你的网络服务器上吗? – 2013-04-26 12:43:07
是的,它已经是他们的@Sam Leach – 2013-04-26 12:56:37