Thursday, 15 February 2018

Send Email to Multiple Recipients(To multiple Emails Id ) in Ax 2012 using X++


Send Email to Multiple Recipients(To multiple Emails Id ) in Ax 2012 using X++



static void Aks_emailcheck(Args _args)
{

SysEmailParameters parameters = SysEmailParameters::find();
SMTPRelayServerName relayServer;
SMTPPortNumber          portNumber;
SMTPUserName             userName;
SMTPPassword               password;
Str1260                            subject,body;
InteropPermission           interopPermission;
SysMailer                        mailer;
System.Exception            e;
 Aks_MailTos                  Aks_MailTos;
 
List                                 emailAddresses;
ListEnumerator              enum;

;
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("akshaykupra@gmail.com");
 
select Aks_MailTos where Aks_MailTos.RecId == 5537144576;
// i took recid this becouse there must be one line which contain multiple mails id with ","
// like i took it in TosEmails fields
emailAddresses = SysEmailDistributor::splitEmail(Aks_MailTos.TosEmails);
enum = emailAddresses.getEnumerator();
while (enum.moveNext())
{
       mailer.tos().appendAddress(enum.current());
}
mailer.ccs().appendAddress("akshaykupra@gmail.com");
mailer.subject(subject);
mailer.htmlBody(body);
mailer.sendMail();
CodeAccessPermission::revertAssert();
info("Email has been send!");
}
catch (Exception::CLRError)

{
e = ClrInterop::getLastException();

while (e)

{
info(e.get_Message());

e = e.get_InnerException();
}
CodeAccessPermission::revertAssert();

info ("Failed to Send Email some Error occure");
}

}




Regards,
Akshay

Multiple action manu item call by single class action manu item



Multiple action manu item call by single class action manu item


Hi All,

This is very simple requirement, client wants one manu item will open code according to legal entity wise. there are three legal entity DEL<MUB<BAN.

you can use according to your requirement. so i created one class and one main Action manu item
i put my this class in new action manu and put it in front.




public static void main(Args _args)
{
    Aks_JVManuITem Aks_JVManuITem;
   MenuFunction menuFunction;

 
            if(curext()=="DEL")
            {

            menuFunction = new MenuFunction(menuitemActionStr(Aks_JVImport_DEL), MenuItemType::Action);
            menuFunction.run();
            }
            if(curext()=="BAN")
            {
            menuFunction = new MenuFunction(menuitemActionStr(Aks_JVImport_BAN), MenuItemType::Action);
            menuFunction.run();
            }
            if(curext()=="MUB")
            {
            menuFunction = new MenuFunction(menuitemActionStr(Aks_JVImport_MUB), MenuItemType::Action);
            menuFunction.run();
            }


}



Regards,
Akshay