WINDOWS Live Search

To contact me for any clarifications regarding any posts / information, please mail me at arijit [dot] basu [at] gmail [dot] com


Thursday, November 23, 2006

Send E Mail from Axapta

SysMailer mailer = new SysMailer();
SysEmailParameters parameters = SysEmailParameters::find();
mailer.fromAddress('arijitbasu@hotmail.com');
mailer.fromName('Pam@anderson.com');
mailer.subject('What are you doing tonite???');
if (parameters.DNSServerName)
{
mailer.DNSServers().add(parameters.DNSServerName,
parameters.DNSTCPIPRetryCount,
parameters.DNSUDPRetryCount);
}

if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServers().add(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPServerIPAddress,
parameters.SMTPUserName,
parameters.SMTPPassword);

}
// Add your own code here, then send the message

======================================================

SysMailer mailer = new SysMailer();
mailer.body("My Body :)");
mailer.subject("WOW Baby");
mailer.fromAddress("Pam@anderson.com");
mailer.fromName("Peter Villadsen");
mailer.tos().add("arijit.basu@gmail.com");
mailer.SMTPRelayServers().add("MyRelayServer");
mailer.sendMail();

======================================================
SysINetMail Mail=new SysINetMail() ;
Mail.sendMailAttach("Pam@anderson.com",
"jul@roberts.com,
"WOW",
"My Body Text ;-)",
false,
"Attachment Path");


All the Best :-)
Happy Mailin...

2 comments:

Anonymous said...

Hello there
Am Using Dynamics AX, and i tried ur code, it seems that mailer.DNSServers() is not there anymore, and whenever i try to run the code it gives me the following Error:
"The SMTP Server Name is required, and was not Found in the Config.Source"
Can you please advice?

Reuben Gathright said...

If you are using Dynamics AX 4.0, you need to first configure your "E-mail parameters" by opening the form found under Administration.

Once complete you can then rely on the sysMailer to autodetect those settings and send your email just by using the following sample code:

public void clicked()
{
SysMailer sysMailer; //[rg] 11/5/2008 Inside MS Dynamics 4.0 Page 176, Part II Developing With AX.
super();
if (box::yesNo("Send email now?",DialogButton::Yes,"Email New Sales Notice?") == DialogButton::Yes )
{
sysMailer = new SysMailer();
sysMailer.quickSend("seller@sales.com","Customer@buyers.com","New Sale","Please review the request by " +

EmplTable::find(SalesTable.SalesResponsible).Name);
info("Notification email sent.");
}
}