functionrazorwebmatrix

Webmatrix email send function


I fully understand how to post some details in a form to send an email, but I am hoping on creating some sort of function/job to do this instead.

How do I create a razor function to do this:

    // Send email
    WebMail.Send(to: customerEmail,
        subject: "Your property is now added",
        body: "Blah Blah Blah"
    );

Is a function even the best way to achieve this? I'm just trying to create reusable code.

I'll need to be able to trigger this in an "if" statement.


Solution

  • You could create a wrapper function (façade) around the WebMail class but since the WebMail class is already a façade around System.Net.Mail, there seems little point, in my opinion.