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)

Unable send email to out side domain in AX 2012

(0) ShareShare
ReportReport
Posted on by 800

Hi,

I have gone through different blogs and forums and didn’t solve my issue.  Can some suggest me on this.. 

Error while sending email :-

1. Getting below error when I am using  System.Net.Mail.SmtpClient, System.Net.Mail.MailMessage  classes

“Mailbox unavailable. The server response was: 5.7.54 SMTP; Unable to relay recipient in non-accepted domain”

2. Getting below error when I am using  "SysMailer" classe:

 

“Method 'send' in COM object of class 'CDO.Message' returned error code 0x8004020F (<unknown>) which means: <unknown>.”

 

Note :- We have existing code for RFQ and written by other developer and it is work fine and it was written by using “System.Net.Mail” and with the same code when I am trying to send email getting above errors.. Tried by implementing same logic in different places like jobs, classes and forms and getting same error.

I have implemented the similar kinds of logic in multiple projects but didn’t face much issues..

Any quick response should be appreciated.

Regards,

KVNKK

*This post is locked for comments

I have the same question (0)
  • A.Prasanna Profile Picture
    8,223 on at

    which email Service you are using ? is it internet email or in house email server ?

    Have you completed SMTP setup correctly ?

  • Suggested answer
    A.Prasanna Profile Picture
    8,223 on at

    How ever if this was working previously without issue it might some thing to do with Mail Server or Service . if you are using MS Exchange Server  2016

    refer link below. Hope it will help.

    practical365.com/.../exchange-2016-smtp-relay-connector

    thanks & Regards,

    Amith Prasanna.

  • kvnkk Profile Picture
    800 on at

    We are using outlook and SMTP setup done properly. I am able to send email with in the internal domain but having issue with outside domain.

    We have existing logic at  RFQ level and it is working fine with internal and external domain.

    Now have used the same logic/method at vendor payment level and it is getting failed for external domain.  Even I have tried with simple job even though same issue.

  • kvnkk Profile Picture
    800 on at

    Below is the code which I am using for sending email :--

    public static void sendPaymet(str sender, str _receipient,str _subject,str _body, str copy='',str _bcc='')

    {

       Args                                    args = new Args();

       CustInvoiceJour                         custInvoiceJour;

       str                                     recipient = _receipient;

       str                                     cc1;

       str                                     subject = _subject;

       str                                     body    = _body;

       Set                                     permissionSet;

       System.Exception                        e;

       str                                     mailServer;

       container                               con;

       int                                     counted;

       int                                     conlength;

       str                                     emails;

       System.Net.Mail.SmtpClient              mailClient;

       System.Net.Mail.MailMessage             mailMessage;

       System.Net.Mail.MailAddress             mailFrom;

       System.Net.Mail.MailAddress             mailTo;

       System.Net.Mail.MailAddress             bcc ;

       System.Net.Mail.MailAddressCollection   mailCCCollection,

                                               mailtocollection;

       str                                     password  =  SysEmailParameters::password();

       SysEmailParameters                      SysEmailParameters = SysEmailParameters::find();

       SrsPrintMgmtExecutionInfo               printMgmtExecutionInfo;

       con       = str2con(recipient,';');

       conlength = conLen(con);

       if (copy)

       {

           cc1=copy;

       }

       sender = SysEmailParameters.SMTPUserName;

       try

       {

           CodeAccessPermission::revertAssert();

           permissionSet = new Set(Types::Class);

           permissionSet.add(new InteropPermission(InteropKind::ClrInterop));

           CodeAccessPermission::assertMultiple(permissionSet);

           mailServer = SysEmaiLParameters::find(false).SMTPRelayServerName;

           mailClient = new System.Net.Mail.SmtpClient(mailServer);

           mailClient.set_EnableSsl(false);

           mailFrom = new System.Net.Mail.MailAddress(sender);

           for (counted =1;counted <= conlength;counted++)

           {

               copy = conPeek(con,counted);

               if (copy =='')

               {

                   continue;

               }

               if (counted ==1)

               {

                   mailTo  = new System.Net.Mail.MailAddress(copy);

                   mailMessage = new System.Net.Mail.MailMessage(mailFrom, mailTo);

               }

               else

               {

                   mailtocollection = mailMessage.get_To();

                   mailtocollection.Add(copy);}

               }

           //cc

           if (cc1)

           {

               mailMessage = new System.Net.Mail.MailMessage(mailFrom, mailTo);

               con = str2con(cc1,';');

               conlength = conLen(con);

               for (counted =1;counted <= conlength;counted++)

               {

                   copy = conPeek(con,counted);

                   if (copy =='')

                   {

                       continue;

                   }

                   mailCCCollection = mailMessage.get_CC();

                   mailCCCollection.Add(copy);

               }

           }

           //Bcc

           if (_bcc && recipient)

           {

               bcc  = new System.Net.Mail.MailAddress(_bcc);

               mailMessage = new System.Net.Mail.MailMessage(mailFrom, mailTo);

               con = str2con(_bcc,';');

               conlength = conLen(con);

               for (counted =1;counted <= conlength;counted++)

               {

                   copy = conPeek(con,counted);

                   if (copy =='')

                   {

                       continue;

                   }

                   mailCCCollection = mailMessage.get_Bcc();

                   mailCCCollection.Add(copy);

               }

           }

           mailMessage.set_Priority(System.Net.Mail.MailPriority::High);

           mailMessage.set_Subject(subject);

           mailMessage.set_Body(body);

           mailMessage.set_IsBodyHtml(true);

           mailClient.set_UseDefaultCredentials(false);

           mailClient.set_Credentials(New System.Net.NetworkCredential(SysEmailParameters.SMTPUserName,Password));

           mailClient.Send(mailMessage);

           mailMessage.Dispose();

           CodeAccessPermission::revertAssert();

       }

       catch (Exception::CLRError)

       {

           e = ClrInterop::getLastException();

           while (e)

           {

               info(e.get_Message());

               e = e.get_InnerException();

           }

           CodeAccessPermission::revertAssert();

      }

    }

  • Suggested answer
    A.Prasanna Profile Picture
    8,223 on at

    Check below details,

    blogs.msdn.microsoft.com/.../sending-emails-from-dynamics-ax-to-external-domains-using-exchange-online

    Regards,

    Amith Prasanna

  • Suggested answer
    Syed Zeeshan Haider Jafry Profile Picture
    725 on at

    Try enabling ssl true

          mailClient.set_EnableSsl(true);

  • kvnkk Profile Picture
    800 on at

    Hi ,

    Issue resolved by resetting the SMTP password.

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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans