Customization: Automail of invoicing

Hi All,

Please tell me how can i do the “Automail of invoicing” in ax 2009 .

For Example- when i post the invoice the automail to the specified Email Address.

Thanks & Regards

Vijay Parashar

Hi,

Here is the sample code(Not tested).

Sysemailparameters form you need to set up the mailserver settings.

SysMailer mailer;
InteropPermission permission=new InteropPermission(InteropKind::ComInterop);
SysEmailParameters parameters;

parameters=SysEmailParameters::find();
mailer = new SysMailer();
mailer.htmlBody(“Hi”);
mailer.subject(“Test Mail”);
mailer.fromAddress(“xxx@aa.com”);
permission.assert();

mailer.tos().appendAddress(“yyy@aa.com”);

mailer.SMTPRelayServer(parameters.SMTPRelayServerName);

mailer.sendMail();
CodeAccessPermission::revertAssert();