ax2009 x++ Error 0x80040211 in RunBaseBatch

674 views Asked by At

I want to send email in RunBaseBatch, but I get error 0x80040211 (unknown).
I found in google that means:

The message could not be sent to the SMTP server. The transport error code was %2. The server response was %1

public void SendReport(str email)
{
   SysMailer      sm = new SysMailer();
   ;
   sm.quickSend("[email protected]", email, "Test", strfmt("body"));
}

This method is called in Run method. And if I copy this source code into job that works. Additionally in Run method I use,

permissionSet = new Set(Types::Class);
permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
permissionSet.add(new InteropPermission(InteropKind::ComInterop));
permissionSet.add(new InteropPermission(InteropKind::DllInterop));
CodeAccessPermission::assertMultiple(permissionSet);
1

There are 1 answers

0
Bjorn Mistiaen On

Because your email seems to work in a job (client side), your email settings in AX are not the issue. This is most likely an authentication issue.

Take a look at this article, which describes what your are experiencing.

On the client side, your current windows user is used to authenticate with the SMTP server.

In batch, the emails are sent from the AOS. That means that the account used for authentication, is the account under which the AOS service runs.

Your mail server probably doesn't accept connections from everyone.
Take a look here on how this is achieved.

You'll have to allow the user that runs your AOS service, to authenticate to your mail server.