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)
Resource paths should be local paths on disk, not URLs.
Write
resources["logo"] = Server.MapPath("~/Content/images/logo.png");