0
votes

When i am sending mail using ActionMailer.Net.Mvc getting a error "Value does not fall within the expected range." below is code.

               var context = System.Web.HttpContext.Current;

                Task.Factory.StartNew(() =>
                {
                    System.Web.HttpContext.Current = context;
                    new MailController().NewsLetter("[email protected]", objNewsModel).Deliver();
                });



    public class MailController : MailerBase
    {
           public EmailResult NewsLetter(string EmailAddress, NewsModel objNewsModel)
           {
               To.Clear();
                To.Add(EmailAddress);
                BCC.Add("[email protected]");
                From = "[email protected]";
                Subject = "Latest News";

                return Email("NewsLetter", objNewsModel); 
   //this (return Email("NewsLetter", objNewsModel);)line giving a error 'Value does not fall within the expected range.'
    }
   }
1

1 Answers

0
votes

I tried your code with an empty custom view Newsletter.txt.cshtml and it works perfect. Try it with an empty view, maybe there is a problem displaying the items.

Please keep in mind also that the ActionMailer is not maintained.