Options

Report Emailing using Outlook

cdsabatier@hotmail.comcdsabatier@hotmail.com Member Posts: 3
edited 2005-08-29 in Dynamics AX
Hi,

I'm hoping someone can help me. As a result of the Rich Text format
issue with non-microsoft mail servers (ie. creating winmail.dat
attachments). We have decided to use Outlook thru COM while emailing
reports. The mail formats are all as we expect, however it is not
handling the attachment correctly.

First you get the message:
This item contains attachments that are potentially unsafe. . . send
anyway ?

Click Yes. It creates the mail with the message - Outlook has
blocked access to the following potentially unsafe attachments:
AxaptaReport.TXT.

Here is the code I have place in the Info Class:

void reportSendMail(PrintJobSettings p1)
{
SysINetMail m = new SysINetMail();

//<NZFS049>
COM outlook;
COM outlookMailItem;
COM outlookAttachments;
//</NZFS049>

// Syp Modifications - SP2 - BEGIN
// Request Num: GB-453-937-TCC7
str fileName = "AxaptaReport";
;

if (p1.format() == PrintFormat::ASCII)
//fileName = subStr(p1.fileName(),strLen(p1.fileName())-3,-
999)+'TXT';
fileName = fileName + '.TXT';
else if (p1.format() == PrintFormat::RTF)
//fileName = subStr(p1.fileName(),strLen(p1.fileName())-3,-
999)+'RTF';
fileName = fileName + '.RTF';
else if (p1.format() == PrintFormat::HTML)
//fileName = subStr(p1.fileName(),strLen(p1.fileName())-3,-
999)+'HTM';
fileName = fileName + '.HTM';
else if (p1.format() == PrintFormat::PDF)
//fileName = subStr(p1.fileName(),strLen(p1.fileName())-3,-
999)+'PDF';
fileName = fileName + '.PDF';

//<NZFS049>
//m.sendMailAttach(p1.mailTo(),p1.mailCc(), p1.mailSubject
(),'Axapta report', FALSE, p1.fileName(), fileName);
//</NZFS049>
// m.sendMailAttach('','', '','Axapta report', TRUE, p1.fileName
(), fileName);

// Syp Modifications - SP2 - END

//<NZFS049>
outlook = new COM('Outlook.Application');
if (outlook)
{
outlookMailItem = outlook.createItem(0);
if (outlookMailItem)
{
outlookAttachments = outlookMailItem.Attachments();
if (outlookAttachments)
{
outlookMailItem.to(p1.mailTo());
outlookMailItem.subject(p1.mailSubject());
outlookMailItem.body('Axapta report');
outlookAttachments.Add(p1.fileName(), 1, 1,
fileName);
outlookMailItem.send();
}

}
}
//</NZFS049>
}

Any help will be appreciated.

Thanks,
Claude

Comments

Sign In or Register to comment.