salestable - methos
---------------------------------------------------
Public void God_SendAlert()
{
DirPersonUser dirPersonUser;
EventNotificationSource _source;
CustTable custTable;
EventNotification event = EventNotification::construct(EventNotificationSource::Sync);
//--- added by kavin for sending email to salesman for cusotmer is on hold 20 aug -2019
GOD_SendEmail god_SendEmail;
Email mainContactWorkerEmail;
//--- added by kavin for sending email to salesman for cusotmer is on hold 20 aug -2019
custTable = CustTable::find(this.CustAccount);
event.parmRecord(custTable);
event.parmUserId(dirPersonUser::findParty(HcmWorker::findRecId(CustTable::find(this.CustAccount).MainContactWorker).Person).User);//curuserid());//user for which this alert to be shown
event.parmDataSourceName('Custtable'); //form datasource
event.parmMenuFunction(new MenuFunction('custtable', MenuItemtype::Display));
event.parmSubject('Customer Unblocking notification for Sales order process');
event.parmMessage(strFmt("Customer %1 is Blocked. Unable to Create Sales order. Kindly take action.",custtable.AccountNum));
//--- added by kavin for sending email to salesman for cusotmer is on hold 20 aug -2019
mainContactWorkerEmail = HcmWorker::emailServer(HcmWorker::find(CustTable::find(this.CustAccount).MainContactWorker).Person);
//info(custtable.AccountNum);
god_SendEmail::sendmail(event.parmSubject('Customer Unblocking notification for Sales order process'),
event.parmMessage(strFmt("Customer %1 is Blocked. Unable to Create Sales order. Kindly take action.",custtable.AccountNum)),
'axsentmails@greenhouseuae.com',mainContactWorkerEmail);
//--- added by kavin for sending email to salesman for cusotmer is on hold -- 20 aug -2019
event.create();
}
------------------------------------------------
class
class GOD_SendEmail
{
}
------------------------------------------------
public static void sendmail(Description _Subject,string255 _body,string50 _fromaddress,string50 _toaddress)
{
SysEmailParameters parameters = SysEmailParameters::find();
SMTPRelayServerName relayServer;
SMTPPortNumber portNumber;
SMTPUserName userName;
SMTPPassword password;
Str1260 subject,body;
InteropPermission interopPermission;
SysMailer mailer;
System.Exception e;
;
if (parameters.SMTPRelayServerName)
relayServer = parameters.SMTPRelayServerName;
else
relayServer = parameters.SMTPServerIPAddress;
portNumber = parameters.SMTPPortNumber;
userName = parameters.SMTPUserName;
password = SysEmailParameters::password();
subject = _Subject;
body = _body; //"<B> " + _body + " </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(_fromaddress);
mailer.tos().appendAddress(_toaddress);
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");
}
}
No comments:
Post a Comment