Wednesday, October 5, 2011

Send Email to multiple recipients using .Net in Dynamics AX

Here is the way to Send Email to multiple recipients  using .Net in Dynamics AX:

    System.Net.Mail.MailMessage             mailMessage;
    System.Net.Mail.SmtpClient              smtpClient;
    str                                     SmtpServer;
    str sub, body, to, fromAddr; 
    
     ;
     
    sub =  "Test Email" ;
    body = "Testing Email, Plz delete this";
    fromAddr = "donotreply@AX-Prod.com";
    to = "user1@test.com,user2@test.com";
    mailMessage = new System.Net.Mail.MailMessage(fromAddr, to);
    SmtpServer = "smtpServer";
    mailmessage.set_Subject(sub);
    mailmessage.set_Body(body);
    smtpClient = new System.Net.Mail.SmtpClient(SMTPServer);
    smtpClient.Send(mailmessage);

Thanks,
San

No comments:

Post a Comment