将图像包含到 MvCMailer Mail 时路径应该如何
我试图在使用 MvCMailer 发送电子邮件时嵌入图像,如下所示:
Dictionary<string,string> resources = new Dictionary<string,string>();
resources["logo"] = new Uri(new Uri(string.Format("{0}://{1}{2}", System.Web.HttpContext.Current.Request.Url.Scheme, System.Web.HttpContext.Current.Request.Url.Authority, Url.Content("~"))), "/Content/images/logo.png").ToString();
mailSender.Confirm(user.Username, user.Email, link,resources).Send();
它是如何生成的:
URI formats are not supported.
我不确定我应该发送什么样的路径,以及如何生成它?
堆栈跟踪:
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.Net.Mail.AttachmentBase.SetContentFromFile(String fileName, ContentType contentType)
at Mvc.Mailer.LinkedResourceProvider.Get(String contentId, String filePath)
im trying to embed an image when sending an email with MvCMailer like this:
Dictionary<string,string> resources = new Dictionary<string,string>();
resources["logo"] = new Uri(new Uri(string.Format("{0}://{1}{2}", System.Web.HttpContext.Current.Request.Url.Scheme, System.Web.HttpContext.Current.Request.Url.Authority, Url.Content("~"))), "/Content/images/logo.png").ToString();
mailSender.Confirm(user.Username, user.Email, link,resources).Send();
How ever it generate this:
URI formats are not supported.
Im not sure what kind of path i should send, and how to generate it ?
Stack Trace:
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.Net.Mail.AttachmentBase.SetContentFromFile(String fileName, ContentType contentType)
at Mvc.Mailer.LinkedResourceProvider.Get(String contentId, String filePath)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
资源路径应该是磁盘上的本地路径,而不是 URL。
写
Resource paths should be local paths on disk, not URLs.
Write
您必须添加代码才能添加附件。
如果这不是权利或权限问题,请尝试此操作
You will have to add the code to do the attachment..
if this is not a rights or permissions issue try this