mvcmailer

MvcMailer: Can't complete NUnit tests on Razor Views which use Url.Action

时间秒杀一切 提交于 2019-12-04 04:29:26
问题 Here's my problem - I am using MvcMailer to create nicely formatted emails using Razor syntax, and it's a great tool to use for that! The issue I'm running into is this - here's some syntax from my View for one of the emails i send: <p>Click here to return to <a href="@Url.Abs(Url.Action("Details", "Home", new{ Id=ViewBag.IdeaId}))">@ViewBag.IdeaName</a></p> Whenever I try to run my unit tests, I get the following error message: Can we send out email notifications for new comments?: System

MVCMailer SendAsync() fails with Amazon SES

六月ゝ 毕业季﹏ 提交于 2019-12-04 04:27:35
问题 If I use Send() with MVCMailer, my SES works fine, but SendAsync() shows the error message below, does anyone know of a work around for this? THanks! System.Net.Mail.SmtpException: Failure sending mail. ---> System.InvalidOperationException: An asynchronous operation cannot be started at this time. Asynchronous operations may only be started within an asynchronous handler or module or during certain events in the Page lifecycle. If this exception occurred while executing a Page, ensure that

How to use MVCMailer without breaking my service layer?

白昼怎懂夜的黑 提交于 2019-12-03 12:28:41
I am looking into using MVcMailer to make nicer emails. However one thing that I am unsure is how to organize the code. I currently have 2 projects. One for mvc and one for my repos and service layers. my 2nd project has no knowledge of MVC and I would like to keep it that way. I am thinking that my smtp code would go into a service layer or wrapper and then I would call it up from other service layers when I need to send emails out. So where does the MVC mailer fit in? Do I generate the body in the controller then pass it to a serivce layer that passes it to my smtp class? MVCMailer seems to

MvcMailer: Can't complete NUnit tests on Razor Views which use Url.Action

旧城冷巷雨未停 提交于 2019-12-01 22:48:06
Here's my problem - I am using MvcMailer to create nicely formatted emails using Razor syntax, and it's a great tool to use for that! The issue I'm running into is this - here's some syntax from my View for one of the emails i send: <p>Click here to return to <a href="@Url.Abs(Url.Action("Details", "Home", new{ Id=ViewBag.IdeaId}))">@ViewBag.IdeaName</a></p> Whenever I try to run my unit tests, I get the following error message: Can we send out email notifications for new comments?: System.ArgumentNullException : Value cannot be null. Parameter name: httpContext Stacktrace - shortened for

MvcMailer unit tests: System.ArgumentNullException httpContext cannot be null

荒凉一梦 提交于 2019-11-30 04:12:31
问题 I cannot successfully run unit tests for MvcMailer using the visual studio test suite and Moq. I have copied the example from the wiki word for word but get the following exception every time: Test method MvcMailerTest.Tests.MailerTest.TestMethod1 threw exception: System.ArgumentNullException: Value cannot be null. Parameter name: httpContext Code is as follows: (Using the VS unit test framework - exact same error when using nUnit as in the example) //Arrange: Moq out the PopulateBody method

Send async e-mails

半腔热情 提交于 2019-11-27 02:47:12
问题 I am using ASP.NET MVC 3 with MVCMailer, I tried to send e-mails using SendAsync, but actually it still take longer. So I am trying to use Task.Factory like the code bellow: var task1 = Task.Factory.StartNew( state => { var mail = new UserMailer(); var msg = mail.Welcome("My Name", "myemail@gmail.com"); msg.SendAsync(); }); task1.Wait(); The problem is, MVCMailer needs HttpContext, but inside this task I got HttpContext Null. How can I send Async e-mails? 回答1: A small addition to this. Here