public static void SendTemplatedEmailExample() { // Creating a Tribal Email message object from a template. // You can specify a user ID or a MailAddress to send the email to // Optionally specify a from address, if none is specified the default site from name and email will be used // Optionally specify a list of parameters var userId = Permission.GetCurrentUserId(); EmailMessage email = TemplatedEmail.EmailMessage(userId, Constants.EmailTemplates.Base); // Use the AddEmailParameter method to set the replacement text, example email.AddEmailParameter("%HTMLBODY%", "Hello world"); // Send the email, the email is added to the queue and processed asynchronously so control is returned immediately to the caller, and the event log gets a log of the email sent with the parameters // The email is sent immediately AppGlobal.EmailQueue.AddToSendQueue(email); // Or all-in-one AppGlobal.EmailQueue.AddToSendQueue( TemplatedEmail.EmailMessage( userId, Constants.EmailTemplates.Base, new List <EmailParameter> { new EmailParameter("%HTMLBODY%", "Hello World") })); }
public static void SendingEmailExample() { // *************************************************************************************************** // Create a normal email object or better use the Tribal one that allows parameter replacements //**************************************************************************************************** // Creating a Tribal Email message object. Omit the 'from address' which will then default to the site standard from address (set in ConfigurationSettings table) EmailMessage email = new EmailMessage("*****@*****.**"); email.Subject = "A subject with a %NAME% place holder"; email.Body = "Hi %NAME% this is a test email."; // Use the AddEmailParameter method to set the replacement text, example email.AddEmailParameter("%NAME%", "Peter Jones"); // %NAME% in the subject and body will be replaced by Peter Jones. // If required add attachments or make other changes as normal as the Tribal email object inherits the standard one so all options are available email.Priority = System.Net.Mail.MailPriority.High; // Send the email, the email is added to the queue and processed asynchronously so control is returned immediately to the caller, and the event log gets a log of the email sent with the parameters // The email is sent immediately AppGlobal.EmailQueue.AddToSendQueue(email); }