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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Error while sending a mail

(0) ShareShare
ReportReport
Posted on by 260

Hi All,

I have used the below code for sending email in AX 2012. I set the correct smtp and port number in the server. 

While executing the code I am getting the below error

"Method ‘send’ in COM object of class ‘CDO.Message’ returned error code 0x8004020F (<unknown>) which means: <unknown>."

static void Job104(Args _args)
{
SysEmailParameters par = SysEmailParameters::find();
SMTPRelayServerName relayserver;
SMTPPortNumber portNumber;
SMTPUserName userName;
SMTPPassword password;
InteropPermission interopPermission;
SysMailer mailer;
Str1260 subject,body;
System.Exception e;

;
if(par.SMTPRelayServerName)
relayserver = par.SMTPRelayServerName;
else
relayserver =par.SMTPServerIPAddress;
portNumber = par.SMTPPortNumber;
userName = par.SMTPUserName;
password =SysEmailParameters::password();
subject ="test mail";
body ="<b>Test mail by Edwin <b>";

CodeAccessPermission::revertAssert();

interopPermission =new InteropPermission(InteropKind::ComInterop);
interopPermission.assert();
mailer =new SysMailer();
mailer.smtpRelayServer(relayserver,portNumber,userName,password,par.NTLM);
mailer.fromAddress("xxx@live.com");
// mailer.fromAddress("xx@ddd.in");
mailer.tos().appendAddress("xxx@ddd.in,xxx@ddd.com");
mailer.ccs().appendAddress("xxx@ddd.com");
mailer.subject(subject);
mailer.sendMail();
CodeAccessPermission::revertAssert();
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Pravasti AK Profile Picture
    2,985 on at

    Hi,

    Try to use the below code:

    void new(COM c = null)

    {

       COM cdoConfig;

       InteropPermission permission = new InteropPermission(InteropKind::ComInterop);

       ;

       permission.assert();

       c = new COM('CDO.Message');

       _COM = c;

       //BP Deviation Documented

       if (_COM.configuration() == null)

       {

           //BP Deviation Documented

           cdoConfig =  new COM('CDO.Configuration');

           _configuration = SysMailerConfiguration::create(cdoConfig);

           //BP Deviation Documented

           this.configuration(_configuration);

       }

       else

       {

           //BP Deviation Documented

           _configuration = SysMailerConfiguration::create(_COM.configuration());

       }

       //BP Deviation Documented

       _fields = _configuration.fields();

       _fields.add(#sendUsing,#cdoSendUsingPort);

       _fields.resync();

    }

  • sivakumar moorthy Profile Picture
    260 on at

    Thank for replying Kavitha, But I tried this  already .

    Regards

    siva kumar

  • Suggested answer
    Pravasti AK Profile Picture
    2,985 on at

    Hi,

    First you have to make the modification in the new() and the sendmail() of the sysmailer class. Also you have to make the setting in the Email parameter form from admin-> email parameter. There you have to give the value of your SMTP server like mail.yourcomp.com , username and the password of that user then only you can send mail from the AX

  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at

    Hi Siva,

    Try to use system.Net classes with example here daxture.blogspot.com.au/search

    Let me know how it goes.

  • Basheer17 Profile Picture
    2,720 on at

    Please refer fredshen.wordpress.com/.../cdo-message-error

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Based on the CDO error code, the recipient address is not valid.

    I can see you have multiple addresses appended separated by a comma, try to use a single entry there instead.

    Ensure that you have a valid e-mail address in your user options, and also listed in your code as from and to addresses.

    Please note that it is advised to use your own SMTP server, and the from e-mail address should match a valid mail account within your domain, otherwise the SMTP server might reject it.

    Also if you use an external mail provider outside of your domain where relaying is disabled, and you are trying to use an e-mail as sender/recipient which is not in compliance with the provider's domain, you will get the same error.

    So, please sort out what SMTP you are using, and with what e-mail address in order to resolve the issue.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans