Bypass warning message when sending email from ax
Original text from: http://ax2009.spaces.live.com/blog/cns! 27f885f1361edc5! 139. Entry
Question:How can I bypass the warning message below when I send the email from ax?
"A program is trying to access e-mail address information stored in outlook ..."
Answer:Mapi related. DLL used by ax is needed to be identified, below are the paths that ax32.exe looks for mapi related DLL (with Office 2007 ). basically all of them are from window and office. you may also want to add ax32.exe to the trust code list in exchange if feasible.
• C:/program files/Microsoft Dynamics ax/50/client/bin/mapi32.dll
• C:/Windows/system32/mapi32.dll
• C:/program files/common files/system/msmapi/1033/msmapi32.dll
• C:/program files/Microsoft Office/office12/olmapi32.dll
• C:/program files/common files/system/msmapi/1033/msmapi32.dll
Please also note that report sent by ax leverage mapi as you already known. end user system may have other email client or mapi application other than outlook. therefore, on top different office version, you also need to deal with other email clients or mapi applications.
You may want to shift the report sending work to SMTP instead if sending report is the primary objective. it is a more light-weighted process, can be scheduled in server-side batch, and more important, shell you from dealing with different mapi application, versions, compatibility issue at each client install base. below is the detail for your reference.
Ax sends report in email using the classess/INFO/reportsendmail. this method in turn uses sysinetmail, which leverage mapi (local mapi app or email client), to send out email. you may use sysmailer class instead which uses SMTP. below is the detail on the sysmailer class
Http://msdn.microsoft.com/en-us/library/aa851352 (ax.10). aspx
If sysmailer class is used, please ensure you have configured the SMTP server in administration-> setup-> E-mail parameters.
Below is the code change sample on Info's reportsendmail () to uses sysmailer instead of sysinetmail for authentication purpose.
<From <
Void reportsendmail (printjobsettings P1)
{
Sysinetmail M = new sysinetmail ();
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 + 'delimiter ';
M. sendmailattach (p1.mailto (), p1.mailcc (), p1.mailsubject (), 'axapta report', true, p1.filename (), filename );
}
>>>>>>> From >>>>>>
<To <
Void reportsendmail (printjobsettings P1)
{
Sysmailer M = new sysmailer ();
STR filename = "axaptareport .";
STR tmpfilename;
STR finalfilename;
Int pathlength;
Int lengthoffilename;
;
// Save the original file name
Tmpfilename = p1.filename ();
// Get the length of the file name and its path
Lengthoffilename = strlen (p1.filename ());
// Get the length of the path without the file name
Pathlength = strscan (p1.filename (), "//", lengthoffilename,-lengthoffilename );
// Assign the report a name = path + filename
Finalfilename = strpoke (p1.filename (), filename, pathlength + 1 );
// Assign the file an extension based off of the printformat
If (p1.format () = printformat: ASCII)
Finalfilename = finalfilename + 'txt ';
Else if (p1.format () = printformat: RTF)
Finalfilename = finalfilename + 'rtf ';
Else if (p1.format () = printformat: HTML)
Finalfilename = finalfilename + 'htm ';
Else if (p1.format () = printformat: PDF)
Finalfilename = finalfilename + 'pdf ';
// Make a copy of the original temp file using the new file's name and extension
Winapi: copyfile (p1.filename (), finalfilename, true );
// Send the email
M. quicksend ('fromaddress @ wherever.com ', p1.mailto (), p1.mailsubject (), 'axapta report', p1.mailcc (), finalfilename );
// Delete the files
Winapi: deletefile (finalfilename );
Winapi: deletefile (tmpfilename );
}
>>>>>>>>>>>>>