Friday, December 24, 2010

Importing an XPO through code

This code helps to import an XPO using X++

static void importXPO(Args _args)
{
SysImportElements sysImportElements = new SysImportElements();
;

sysImportElements.newFile("C:\\Form_KranthiTest.xpo");/// this is your XPO filename
sysImportElements.parmImportAot(true);
sysImportElements.parmImportWithIds(false);///if you don't to import with IDvalues
sysImportElements.import();
}

Monday, December 13, 2010

Sending mails through outlook

This code open an mail window form - to which you can send parameters like email id , subject and body

static void sendEmailThroughOutlook(Args args)
{
SmmOutlookEMail smmOutlookEMail = new SmmOutlookEMail();
Object smmSendEmail;
;

args = new Args();
args.name(formstr(smmSendEmail));
args.caller(smmOutlookEMail);
smmSendEmail = classfactory.formRunClass(args);


if (smmSendEmail)
{
smmSendEmail.init();
smmSendEmail.setEmailTos("aaa@gmail.com");
smmSendEmail.setEmailSubject("Kranthi");
smmSendEmail.setAttachments(["C:\AIF\kranthi.txt"]);
smmSendEmail.run();
smmSendEmail.refreshControl();
smmSendEmail.wait();
}

}