Tuesday, 16 June 2015

Create dialog, Sending mail ,Send SMS in Axapta through code.

Job for creating Dialog Box.

static void Axapta_DialogBox(Args _args)
{
Dialog dl;
DialogGroup dlg;
DialogField dlF;
DialogBox dBx;
dl= new dialog(“Dialog Box”);
dlg= dl.addGroup(“Customer”);
dlF= dl.addField(extendedTypeStr(CustAccount));
dlg= dl.addGroup(“Customer Group”);
dlF= dl.addField(extendedTypeStr(CustGroupId));
if (dl.run())
dlf.value();
}

Code for sending mail in Ax

static void SendMail(Args _args)
{
PrintjobSettings printjobSettings;
PurchTable Ptbl;
vendtable vtbl;
QueryBuildDataSource qbd;
ReportRun report;
Args args = new Args();
RecordSortedList List = new RecordSortedList(62);
sysMailer mailer;
str _fileName;
str fromAddr;
str toAddr;
str subject;
str body;
str cc;
#AviFiles
SysOperationProgress progress = new SysOperationProgress();
int i;
if (Box::yesNo(‘Do you want to Send a mail ?’, DialogButton::No) == DialogButton::Yes)
{
progress.setCaption(“My Task”);
progress.setAnimation(#AviUpdate);
progress.setTotal(50000);
mailer = new sysMailer();
fromAddr = ‘sender mail id’ ;
toAddr = ‘rec Mail Id’ ;
subject = ‘Axapta Mail sent';
Body = ‘Purchase Order Report';
cc = ‘CC mail id’ ;
mailer.quickSend(fromAddr,toAddr ,subject,Body,cc,_fileName);
info(‘E-Mail is Sent Successfully aginst %1 this document number’);
//files deleted in ax folder
if (!isRunningOnServer())
{
if(WinAPI::fileExists(_fileName))
{
WinAPI::deleteFile(_fileName);
}
}
}
}

Send SMS in Axapta with intergration of webclient

Create a method in class and integrate Ax with webclient

str sendSMS(str txtTo, str txtMessage)

{
str txtUserName, txtPassword, txtSender, txtURL, txtGateway, txtCDMASender;
str txtResponse, txtSendString;
System.Net.WebClient cust;
System.IO.Stream data;
System.IO.StreamReader reader;
InteropPermission perm;

;
perm = new InteropPermission( InteropKind::ClrInterop );
txtUserName = ‘ABCD';
txtPassword = ‘abcd@123′;
txtSender = ‘XYZ';
txtGateway = ‘trans';
txtCDMAsender = ‘XXXXXXXXXX';
perm.assert();
cust = new System.Net.WebClient();

txtURL = ‘http://india.timessms.com/http-api/receiverall.asp?’ +
‘username=’ + txtUsername + ‘&password=’ + txtPassword +
‘&sender=’ + txtSender + ‘&cdmasender=’ + txtCDMASender + ‘&to=’ +
txtTo + ‘&message=’ + txtMessage + ‘&Gateway=’ +txtGateway;
data = cust.OpenRead(txtURL);

reader = new System.IO.StreamReader(data);

txtResponse = reader.ReadToEnd();
data.Close();
reader.Close();
return txtResponse;

}

1 comment:

Import General journal from excel in D365 F&O

 Hi Guys, Import General journal from excel in D365 F&O Code:  using System.IO; using OfficeOpenXml; using OfficeOpenXml.ExcelPackage; u...