crossvertise / ActionMailerNext

Fork of ActionMailer.Net, A easy to use library to generate emails with razor views
MIT License
42 stars 24 forks source link

Samples #12

Open DoubleExposure opened 9 years ago

DoubleExposure commented 9 years ago

Examples are unclear. Also, using UNIT Test Mock references make it even more unclear.

I have not tried this yet but would this work based off of how the old version worked? If this works then please use something like this for an example. If this does not work can you provide a better example?

INewEmailModel mailmodel = new NewEmailModel();
        mailmodel.From = "joe@joe.com";
        mailmodel.To = "sam@sam.com";
        mailmodel.Name = "sam spade";
       mailmodel.Subject = : Password Reset by Admin Notification";
       mailmodel.NewPassword = "mypassword123";
       new MailController().PasswordResetEmail(mailmodel).DeliverAsync();

//In Controller

public EmailResult PasswordResetEmail(INewEmailModel model)
    {
        SetHeaders(model);
        return Email("PasswordResetEmail", model);
    }

private void SetHeaders(INewEmailModel model)
    {
        SetMailMethod(MailMethod.SMTP);

        MailAttributes.To.Add(new MailAddress(model.To));
        if (!string.IsNullOrWhiteSpace(model.Cc)) MailAttributes.Cc.Add(new MailAddress(model.Cc));
        if (!string.IsNullOrWhiteSpace(model.Bcc)) MailAttributes.Bcc.Add(new MailAddress(model.Bcc));
        MailAttributes.From = new MailAddress(model.From);
        MailAttributes.From = new MailAddress(model.Subject);

    }
hydr commented 9 years ago

By quickly looking at it I would say that it shoud work.

The new version is not 100% compatible with the old version, but it is very similar.