I need to send mail to multiple to address not CC/BCC.
Using SysMailer
-To address come from Table
Now i could send mail to only one person, using hardcore the mail address
Waiting for your reply
Thanks,
Jeevanandham
Jeevanandham said:Now i could send mail to only one person, using hardcore the mail address
What does that mean? Can you please explain or show us the code?
static void SendEmail(Args _args)
{
SysEmailParameters parameters = SysEmailParameters::find();
SMTPRelayServerName relayServer;
SMTPPortNumber portNumber;
SMTPUserName userName;
SMTPPassword password;
Str1260 subject,body;
InteropPermission interopPermission;
SysMailer mailer;
System.Exception e;
OEMImportConfigurationTest OEM;
List toAddr;
ListEnumerator lenum;
str toAddress = OEM.Email;
if (parameters.SMTPRelayServerName)
relayServer = parameters.SMTPRelayServerName;
else
relayServer = parameters.SMTPServerIPAddress;
portNumber = parameters.SMTPPortNumber;
userName = parameters.SMTPUserName;
password = SysEmailParameters::password();
subject = "Subject line for the email";
body = "<B>Body of the email</B>";
CodeAccessPermission::revertAssert();
try
interopPermission = new InteropPermission(InteropKind::ComInterop);
interopPermission.assert();
mailer = new SysMailer();
mailer.SMTPRelayServer(relayServer,portNumber,userName,password, parameters.NTLM);
//instantiate email
mailer.fromAddress(userName);
toAddr = SysEmailDistributor::splitEmail(OEM.Email);
lenum = toAddr.getEnumerator();
lenum.moveNext();
while(lenum.moveNext())
mailer.tos().appendAddress(lenum.current());
}
//mailer.tos().appendAddress();
mailer.subject(subject);
mailer.htmlBody(body);
mailer.sendMail();
info("Email has been send!");
catch (Exception::CLRError)
e = ClrInterop::getLastException();
while (e)
info(e.get_Message());
e = e.get_InnerException();
info ("Failed to Send Email some Error occure");
Trying this code now but how to fetch to address from table
OEM.Email field consist the data like " abc@xy.com,asd@xy.com,sdf@xy.com "
from this data i need to split those three mail address and need to send mail for those three mailid
https://www.tech.alirazazaidi.com/sending-email-using-x-code-dynamics-ax-2012/
https://ievgensaxblog.wordpress.com/2016/06/11/ax-2012-sysemaildistributor-does-not-send-emails-to-multiply-recipients/
This two links i followed.....