Closed dieterdp closed 10 years ago
this triggers the exception var imageEmbedder = (ImageEmbedder)html.ViewData["Postal.ImageEmbedder"];
I seem to be getting this too. Is there any way to get this fixed or a work around we could employ to get this to work?
I also have experienced the same issue. I am wondering if I am missing some dependency. It is a little bit of a pain as this plugin is so easy to use else-wise.
The workaround is to only use "Embed Images" using multi-part emails (ie, one that has both plain-text and html views). Obviously, you only put the image in the HTML view. :) The example supplied in the documentation does not work.
Thank you Pharylon for your prompt response. I very much appreciate the heads up so we can continue with our application development knowing how to move forward effectively.
I have tested pharylon's response and it is correct. You must create a text and html version of the email if you would like to use embed images. A bit frustrating seeing as this isn't specified anywhere. I only needed to create html version as this was used in an internal application. And to find out I needed to create dummy text versions just to get this to work was bewildering.
Thus, for any future users who might come across this issue, follow this guide http://aboutcode.net/postal/multi-part.html and then the images should work.
Fixed in v1.1.0
Hello
When i use @Html.EmbedImage i always get a nullreference exception. I am using MVC 5.1
regards Dieter
at Postal.HtmlExtensions.EmbedImage(HtmlHelper html, String imagePathOrUrl, String alt) at ASP._Page_Views_Emails_Demo_cshtml.Execute() in c:\Temp\PostalTest\PostalTest\Views\Emails\Demo.cshtml:line 6 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.StartPage.RunPage() at System.Web.WebPages.StartPage.ExecutePageHierarchy() at System.Web.WebPages.StartPage.RunPage() at System.Web.WebPages.StartPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at Postal.EmailViewRenderer.RenderView(IView view, ViewDataDictionary viewData, ControllerContext controllerContext) at Postal.EmailViewRenderer.Render(Email email, String viewName) at Postal.EmailService.CreateMailMessage(Email email) at Postal.EmailService.Send(Email email) at Postal.Email.Send() at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid1[T0](CallSite site, T0 arg0) at PostalTest.Controllers.HomeController.Index() in c:\Temp\PostalTest\PostalTest\Controllers\HomeController.cs:line 18 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionaryb39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultb 3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>cDisplayClass48.b 41()
2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod() at System.Web.Mvc.Async.AsyncControllerActionInvoker.2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase
1.End() at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag) at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.