Every time an e-mail is sent through Outlook from AX, you are prompted with “Choose Profile”

In this scenario the user is running AX via Remote Desktop (Terminal Server), and they typically do not have Outlook running in the background. In this case whenever the user sends an e-mail from AX, Outlook is started, but they always prompted with the “Choose Profile” window to select a profile. In this window, you can click on Options, and select “Set as default profile. Unfortunately, setting this option does not stop the Choose Profile window from opening in the future. If Outlook is running they won’t be prompted for this, however as AX is a published remote app, they cannot start Outlook.

The issue is due to the following code: Class\Method – SmmOutlookEMail::createMailItem
At line 16: this call is made – outlookNameSpace.logon();

If you look at the following TechNet article you will see for Outlook 2010 and Outlook 2013 this will always cause the Choose Profile window to appear:


There is no need to make this call, as Outlook will still be initialized using the default profile the user has. The workaround is to just remote/comment out this line, see code below:

The issue is due to the following code: Class\Method – SmmOutlookEMail:: createMailItem
At line 16: this call is made – outlookNameSpace.logon();

12        try
13        {
14            outlook = new COM (#outlookapplication);
15            outlookNameSpace = outlook.getNameSpace(#mapi);
16            //outlookNameSpace.logon();    //This will not prompt to choose profile
17            folder = outlookNameSpace.getDefaultFolder(#olFolderInbox);
18            item = outlook.createItem(#olMailItem);
19            item.save();
20            storeId = folder.storeId();
22            if(item)
23               {
24                   ret = true;
25                }
26        }



“Microsoft provides programming examples for illustration only, without warranty expressed or implied, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. This mail message assumes that you are familiar with the programming language that is being demonstrated and the tools that are used to create and debug procedures.” This is not an officially tested solution by Microsoft and should be fully tested before implementation.

Thanks to the contributors James Wang & Thomas Treen