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