Skip to content

OnMailSending is never executed #36

@jbreuer

Description

@jbreuer

I've overriden the OnMailSending method, but it's never hit. This is my controller:

public class EmailController : MailerBase
{
    public EmailResult BaseEmail(BaseEmailViewModel mail)
    {
        this.MailAttributes.From = new MailAddress(mail.MailFrom);
        this.MailAttributes.To.AddRange(mail.MailTo.Select(s => new MailAddress(s)));
        this.MailAttributes.Bcc.AddRange(mail.MailToBcc.Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => new MailAddress(s)));
        this.MailAttributes.Subject = mail.MailSubject;
        this.MailAttributes.MessageEncoding = new UTF8Encoding();
        return this.Email("BaseEmail", mail);
    }

    protected override void OnMailSending(MailSendingContext context)
    {
        //Cancel for testing.
        context.Cancel = true;

        base.OnMailSending(context);
    }
}

We send the email like this:
new EmailController().BaseEmail(emailViewModel).Deliver();

Is there an example on how to implement OnMailSending ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions