Tuesday, April 27, 2010

Emailing Techniques in Dynamics AX or Emailing through X++

E-mailing in Axapta

static void EmailSendingthroughSmmoutlook(Args _args)
{
   SmmOutlookEmail      smmOutlookEmail =   new     SmmOutlookEmail();
   str                  email;
   ;
   if (smmOutlookEmail.createMailItem())
   {
        smmOutlookEmail.addEMailRecipient('pujar.nikhil@gmail.com');
        smmOutlookEmail.addEMailRecipient('lincen_louis@yahoo.com');
        smmOutlookEmail.addSubject("Test Message from Axapta");
        smmOutlookEmail.isHTML(true);
        smmOutlookEmail.addBodyText('Hi Was just tryin to Send Email through Axapta           :)');
        smmOutlookEmail.sendEMail(smmSaveCopyofEmail::No);

    }
}

The above technique will use Microsoft Outlook and create a Email for you but will not send it Problematically you will have to hit send button if you want to send the email.

Here is another technique which will not only create an E-mail but will send also....    :)

    static void emailThruSysInetMail(Args _args)
    {
        SysInetMail mail = new SysInetMail();
        ;
        mail.sendMailAttach('lincen_louis@yahoo.com ', 'pujar.nikhil@gmail.com', 'Test mail from Axapta',         'Hi  There Was tryin to Send email through Axapta :)', false,"");
        SysInetMail::sendEMail('Alerts', 'en-us', 'nikhil.pujar@Solugenix.com');


    }

1 comment:

  1. SysInetMail::sendEMail('Alerts', 'en-us', 'nikhil.pujar@Solugenix.com');

    In above code,, if i have to attach a file., how can i acheive that..

    ReplyDelete