首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用postal在hangfire中发送电子邮件

使用postal在hangfire中发送电子邮件
EN

Stack Overflow用户
提问于 2015-12-17 17:44:12
回答 1查看 1.4K关注 0票数 0

我使用的是hangfire,DI使用的是autofac。我想使用postal.mvc5工具发送电子邮件,但收到以下错误:

代码语言:javascript
复制
System.InvalidOperationException

The request lifetime scope cannot be created because the HttpContext is not available.

System.InvalidOperationException: The request lifetime scope cannot be created because the HttpContext is not available.
   at Autofac.Integration.Mvc.RequestLifetimeScopeProvider.GetLifetimeScope(Action`1 configurationAction)    
   at Autofac.Integration.Mvc.AutofacDependencyResolver.get_RequestLifetimeScope()
   at Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(Type serviceType)
   at System.Web.Mvc.BuildManagerViewEngine.DefaultViewPageActivator.Create(ControllerContext controllerContext, Type type)
   at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
   at Postal.EmailViewRenderer.RenderView(IView view, ViewDataDictionary viewData, ControllerContext controllerContext, ImageEmbedder imageEmbedder)
   at Postal.EmailViewRenderer.Render(Email email, String viewName)
   at Postal.EmailService.Send(Email email)
   at Postal.Email.Send()
   at Store.Web.Controllers.HomeController.Test() in C:\Users\a\Documents\Visual Studio 2015\Projects\In\S.Web\Controllers\HomeController.cs:line 33

我搜索了2天,没有找到关于这个问题的任何东西。请帮帮我!谢谢

EN

回答 1

Stack Overflow用户

发布于 2017-01-02 19:15:21

http://docs.hangfire.io/en/latest/tutorials/send-email.html#installing-postal

从上面的链接中解释。您不能使用Viewbag或template在httpcontext之外发送电子邮件。您必须使用模型而不是Viewbag,嵌入的图像也不能使用(请参阅http://aboutcode.net/postal/outside-aspnet.html)

对于嵌入的图像,您可以通过模型传递,请参阅此处以获得更多解释https://github.com/andrewdavey/postal/issues/44

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34331291

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档