Quantcast
Channel: Martin Dráb's Activities
Viewing all articles
Browse latest Browse all 17532

Unable to Send Email in One Box Environment. Operation has been timed out while sending Email using SMTP Server Connection.

$
0
0

Hi Folks,

I am unable to send Email in Onebox Environment using a Simple Runnable Class below, and I am getting following Error,

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.Mail.SmtpException: The operation has timed out.
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at Dynamics.AX.Application.SysMailerSMTP.`sendNonInteractive(MailMessage _message) in xppSource://Source/ApplicationFoundation\AxClass_SysMailerSMTP.xpp:line 71
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Dynamics.AX.Application.SysMailerFactory.`logSendFailure(String _mailerName, Exception _exception) in xppSource://Source/ApplicationFoundation\AxClass_SysMailerFactory.xpp:line 188
at Dynamics.AX.Application.SysMailerFactory.SysMailerFactoryCoCHelper.`logSendFailure(SysMailerFactory instance, String arg0, Exception arg1)

But The same code works in Azure Environment and I can able to see the messages being sent.

Please find the code snippet for the Runnable class  and attached Screen shot of SMTP configuration in D365 FO,

Please help me to figure out whether I am missing Something,

Thanks in Advance.

    public static void main(Args _args)
    { 
        InteropPermission interopPermission;
        System.Exception  ex;

        interopPermission = new InteropPermission(InteropKind::ClrInterop);
        interopPermission.assert();

        try
        {
            var builder = new SysMailerMessageBuilder();

            builder.setFrom("raghunathM@xxxxorganization.com");
            builder.addTo("gopiM@xxxxorganization.com");


            builder.setSubject("Hiiiiii");
            builder.setBody("Test email Sending");
    
            var message = builder.getMessage();

            SysMailerFactory::getNonInteractiveMailer().sendNonInteractive(message);
        }
        catch (Exception::CLRError)
        {
            ex = ClrInterop::getLastException();
            if (ex != null)
            {
                ex = ex.get_InnerException();
                if (ex != null)
                {
                    error(ex.ToString());
                }
            }
        }
    }

Viewing all articles
Browse latest Browse all 17532

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>