web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Mapi class not working?

(0) ShareShare
ReportReport
Posted on by 811

Hi, I am trying to connect to mail using Mapi class.

However, following code returns an error (MAPI_E_CALL_FAILED 80004005 -2147467259)

static void SVJOOTestMail(Args _args)
{
    #Mapi
    Mapi        m = new Mapi();
    int         ret;
    ;
    ret = m.logon("","", #MAPI_USE_DEFAULT);
   
    info(strfmt("%1",ret));
}

However, when I use .net in X++ it works fine:

    imap = new System.Net.Imap.ImapClient();
    try
    {
        imap.set_AuthMethod("LOGIN");
        imap.set_Port(143);
        imap.set_Ssl(false);
        imap.Connect("mailsrvx");
        netString = imap.Capability();
        info(strfmt("%1", ClrInterop::getAnyTypeForObject(netString)));
        if (imap.Login("user@domain.be","password"))
            info("Login Succesfull");
        else
            info("Login Failed");

...

Any ideas why standard AX Mapi is not working?

 

Thanks,

 

Sven

*This post is locked for comments

I have the same question (0)
  • Jonathan  Halland Profile Picture
    11,310 on at

    Hi Sven

    Were you ever able to solve this issue? We're also looking into retrieving mail from a pop or imap account but havent been able to find anything thus far.

    Regards

    Jonathan

  • Sven Joos Profile Picture
    811 on at

    Hi Jonathan,

    you cannot use the mapi class of AX, since MAPI != IMAP ;-). It took me some time to figure this out also.

    However, I was able to connect to an exchange inbox using a freeware IMAP DLL from

    hellowebapps.com/.../imapx

    Put the .dll in the bin directory of AX Server and Client directories and add it as a reference in the AOT and you can use the library!

    Good luck!

    KR,

    Sven

  • Jonathan  Halland Profile Picture
    11,310 on at

    Hi Sven.

    Thank you so much for that suggestion. It has proved to be very helpful to do what we are setting out to do.

    Have you been able to run any form of code on the server side using this specific DLL? We are trying to run a job in batch mode and it is not allowing me to as it cannot locate the DLL.

    We have furthermore not been able to add the DLL to the GAC because it is not strongly named.

    Thanks again!

    Jonathan

  • Brandon Wiese Profile Picture
    17,790 on at

    If indeed Exchange is your mailstore, you can use Microsoft's Exchange Web Services Managed API and drop the DLL's in either the client or server Bin folder.  Note that which Bin folder you use determines where the code can be run.  You can find more information about that --

    msdn.microsoft.com/.../dd633709(v=EXCHG.80).aspx

    While I believe it works server-side, I have not attempted to use it there yet.  I prefer to use it on the client and take advantage of pass-through authentication.  This allows users to work with their own Inbox from within AX or other .NET code without being prompted for a username or password.  You can also send e-mail with it easily again without warnings or authentication.

    It is not necessary to install the DLL in the GAC.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sanhthosh.Kumar.K Profile Picture

Sanhthosh.Kumar.K 2

#2
Raed Salah Bzour Profile Picture

Raed Salah Bzour 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans