zoukankan      html  css  js  c++  java
  • Bypass warning message when sending email from AX

    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 illustration 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 + '.pdf';

    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);
    }
    >>>>>>>To>>>>>>>
  • 相关阅读:
    读《SQL优化核心思想》:你不知道的优化技巧
    MySQL 索引建立原则及注意事项
    MySQL 捕获有问题的SQL-慢查日志 实例
    MySQL 分区间进行数据展示 实例
    MySQL 删除重复数据实例
    MySql 索引优化实例
    JDK1.6 Java.lang.Null.Pointer.Exception
    关于 MySQL LEFT JOIN 不可不知的事
    搞定queryString
    数据库不得不说的陷阱
  • 原文地址:https://www.cnblogs.com/Fandyx/p/2761433.html
Copyright © 2011-2022 走看看