In X++ there are many functionality to send mail from X++. Dynamics AX Are very Use full in Entity Relation Ship Programming. Here i Will Create A Job in AX 2012 How to Send Mail From AX in G Mail or Outlook Server. Here you can Add Attachment, or Else you can Put your Friends in CC, Give Subject Name, Send Body Of Code or Content in AX.
static void mail_from_ax(Args _args)
{
Description255 recipientEmail;
Notes emailBody;
Description255 subjectText;
Filename fileName;
SmmOutlookEmail smmOutlookEmail = new SmmOutlookEmail();
recipientEmail = "RecipientEmail@gmail.com";
subjectText = "Test Email";
// fileName = @"C:\Users\admin\Desktop\mypic.jpg";
emailBody = "Hi,\nThis is a test email for Dyanmics AX.\nThanks.";
if (smmOutlookEmail.createMailItem())
{
smmOutlookEmail.addEMailRecipient(recipientEmail);
smmOutlookEmail.addSubject(subjectText);
//smmOutlookEmail.addFileAsAttachment(fileName);
smmOutlookEmail.addBodyText(emailBody);
smmOutlookEmail.sendEMail(smmSaveCopyOfEMail::No,false);
//smmOutlookEmail.sendEMail(smmSaveCopyOfEMail::Yes,NoYes::Yes);
Box::info("Mail Send Successfully !!");
}
else
{
error("Could not communicate with Microsoft Outlook Client.");
}
}
static void mail_from_ax(Args _args)
{
Description255 recipientEmail;
Notes emailBody;
Description255 subjectText;
Filename fileName;
SmmOutlookEmail smmOutlookEmail = new SmmOutlookEmail();
recipientEmail = "RecipientEmail@gmail.com";
subjectText = "Test Email";
// fileName = @"C:\Users\admin\Desktop\mypic.jpg";
emailBody = "Hi,\nThis is a test email for Dyanmics AX.\nThanks.";
if (smmOutlookEmail.createMailItem())
{
smmOutlookEmail.addEMailRecipient(recipientEmail);
smmOutlookEmail.addSubject(subjectText);
//smmOutlookEmail.addFileAsAttachment(fileName);
smmOutlookEmail.addBodyText(emailBody);
smmOutlookEmail.sendEMail(smmSaveCopyOfEMail::No,false);
//smmOutlookEmail.sendEMail(smmSaveCopyOfEMail::Yes,NoYes::Yes);
Box::info("Mail Send Successfully !!");
}
else
{
error("Could not communicate with Microsoft Outlook Client.");
}
}
No comments:
Post a Comment