Last active
December 19, 2015 06:09
-
-
Save davidalencar/5908918 to your computer and use it in GitHub Desktop.
Sending e-mail via Dynamics Ax with .NET framework. Server with authentication SSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void jobEmail(Args _args) | |
{ | |
System.Net.Mail.SmtpClient mailClient; | |
System.Net.NetworkCredential credentials; | |
System.Net.Mail.MailMessage mailMessage; | |
; | |
mailClient = new System.Net.Mail.SmtpClient(); | |
mailClient.set_DeliveryMethod(System.Net.Mail.SmtpDeliveryMethod::Network); | |
mailClient.set_Host('smtp.domain.com'); | |
mailClient.set_Port(587); | |
credentials = new System.Net.NetworkCredential("user@domain.com", "password"); | |
mailClient.set_UseDefaultCredentials(false); | |
mailClient.set_Credentials(credentials); | |
mailMessage = new System.Net.Mail.MailMessage("email_From@domain.com", "email_To@domain.com"); | |
mailMessage.set_Subject("Subject Email Test"); | |
mailMessage.set_Body("Body Email Test"); | |
mailMessage.set_IsBodyHtml(false); | |
try | |
{ | |
mailClient.Send(mailMessage); | |
} | |
catch (Exception::CLRError) | |
{ | |
info("Error:" + AifUtil::getClrErrorMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment