tumblr tracker

SendEmail

Library Reference ›› Email ››
Parent Previous Next

Email.SendEmail


Namespace: Email


Sends a previously created email message.


retval = Email.SendEmail(EmailMessage, SmtpClient)


Parameters:

- EmailMessage; previously created and populated email message

- SmtpClient; a handle variable returned from a previous call to CreateSmtpClient or CreateSecureSmtpClient


Returns:

True if email was sent, false otherwise; boolean value.


Example


//the below code checks if there's an error and sends the error message if there is one
if (Error.IsError())
{
   $Error = Error.GetErrorMessage();
   
   $EmailMessage = Email.CreateEmailMessage();
   
   $EmailMessage:FromEmailAddress = "someuser@somedomain.com";
   $EmailMessage:ToEmailAddress = "someotheruser@someotherdomain.com";
   $EmailMessage:Subject = "There was an error";
   $EmailMessage:MessageBody = $Error;

   $SmtpClient = Email.CreateSmtpClient("mail.somedomain.com", 25, "someuser@somedomain.com", "somepassword");
     
   If (Error.IsError() == False)
   {
       Email.SendEmail($EmailMessage, $SmtpClient);
   }
}