andrewdavey / postal

Email sending for asp.net mvc using the view engine system to render emails.
http://aboutcode.net/postal
MIT License
536 stars 168 forks source link

Views located in area view are not found by view engine #132

Closed timdooling closed 8 years ago

timdooling commented 8 years ago

I have an administrative view area and the view engine will not find any view located in the administrative area

I have determined the problem is in the location determined by UrlRoot().

This location only returns the root of the web application, not the current offset in the application, so it won't work for areas in mvc.

Is there any way this can be altered so that areas can be supported, such as adding an option to set a namespace or something similar to search for the view?

hermanho commented 8 years ago

https://github.com/zabeda/postal

timdooling commented 8 years ago

The below code is what we are using and it still does not work:

        dynamic email = new Email(mailViewModel.workingGroupName.Replace(" ", String.Empty));
        email.To = String.Join(",", memberListViewModelRepository.GetWorkingGroupEmail(mailViewModel.workingGroupName));
        if (String.IsNullOrEmpty(email.To))
        {
            return RedirectToAction("EmptyGroup");
        }

        email.Subject = mailViewModel.subject;

        email.MainBody = mailViewModel.mailMessage;
        email.AreaName = "AdminApplications.Areas.Administrator";
        email.Send();

What is the problem with our code?

hermanho commented 8 years ago

try

dynamic email = new Email(mailViewModel.workingGroupName.Replace(" ", String.Empty), "Administrator");
timdooling commented 8 years ago

The compiler gives me an unknown constructor error and won’t compile.

From: hermanho [mailto:notifications@github.com] Sent: Tuesday, January 19, 2016 1:40 AM To: andrewdavey/postal postal@noreply.github.com Cc: timdooling timothydooling@gmail.com Subject: Re: [postal] Views located in area view are not found by view engine (#132)

try

dynamic email = new Email(mailViewModel.workingGroupName.Replace(" ", String.Empty), "Administrator");

— Reply to this email directly or view it on GitHub https://github.com/andrewdavey/postal/issues/132#issuecomment-172765129 .

timdooling commented 8 years ago

The constructor takes only one argument and two won't compile.

hermanho commented 8 years ago

Please get the source code from https://github.com/zabeda/postal and compile. This version is supported the area

timdooling commented 8 years ago

Yeah, I noticed that this branch was not merged to the main one. The master branch does not have a multi-parameter constructor for Email.

I have compiled it and it does work. A nugget package for this version would be helpful.