Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Emails Notification problems

Posted on by 55

Hello ALL,

Please find below the case that I encountered during my tests:

Case 1 : send a simple email result OK => receipt of email

Case 2 : send two different emails but not in the same minute( time) , Result OK => receipt of both emails

Case 3 : send two different emails in the same minute  result KO => receipt of a single email !!! ???  normally I should receive two emails

Thank you for your help

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,253 Super User 2024 Season 2 on at
    RE: Emails Notification problems

    Hi Hassan,

    Unfortunately, I'm not able to create a reproducible scenario. Have you already tried to use the outgoing email option with the batch job?

  • Hassan EL Alama Profile Picture
    Hassan EL Alama 55 on at
    RE: Emails Notification problems

    Hi André,

    Yes is related to my first question, I just executed the code for sending email (at the top) two time in the same minute.

    i think is related to SSL/ TLS 1.0 /TLS 1.2 version !

    Thanks,

    Hassan

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,253 Super User 2024 Season 2 on at
    RE: Emails Notification problems

    Hi Hassan,

    Can you tell if this is related to this question? If so, what have you done exactly to get this error?

  • Hassan EL Alama Profile Picture
    Hassan EL Alama 55 on at
    RE: Emails Notification problems

    Thank you André,

    i can now catch the exception :

    6761.Exception.PNG

    EXception: Received an unexpected EOF or 0 bytes from the transport stream

    Any solution to suggest ? 

    Thanks

    Hassan

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,253 Super User 2024 Season 2 on at
    RE: Emails Notification problems

    Hi Hassan,

    I have not done this myself. There are examples in the standard where this function is used. E.g. timesheet and workflow notifications. You can review how it has been done by reverse engineering.

  • Hassan EL Alama Profile Picture
    Hassan EL Alama 55 on at
    RE: Emails Notification problems

    Hello André,

    Thank you for your answer, it's clear.

    Do you have any idea how i can do this by using my initial code?

    Best regards,

    Hassan

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,253 Super User 2024 Season 2 on at
    RE: Emails Notification problems

    Hi HEL,

    The coding is sending emails directly. In that case, indeed the Email sending status form is not used. Using this code, you have to review Exchange server settings to see what might be wrong here. The coding is taking care of exceptions. You are never receiving an error when it is failing?

    You can also consider to refactor the code to use the outgoing emails table. Then a batch job will take care of sending and then you can also set the retry mechanism.

  • Hassan EL Alama Profile Picture
    Hassan EL Alama 55 on at
    RE: Emails Notification problems

    Hello All,

    Thank you for your answers :)

    Here is my code is running by a bouton in form, I can't see the list of sent emails so see the status of each email if it's sent or blocked or pending !! 

    Do you have any idea on how to view and reprocess blocked emails ? 

    FYI : The table outgoingEmailTable is empty

    pastedimage1596730326817v1.png

    public void sendMail()

    {

       SysEmailParameters      emailParameters = SysEmailParameters::find();

       SMTPRelayServerName     relayServer;

       SMTPPortNumber          portNumber;

       SMTPUserName            userName;

       SMTPPassword            password;

       Str1260                 subject;

       Str1260                 body;

       InteropPermission       interopPermission;

       SysMailerNet            mailer;

       System.Exception        e;

       MapEnumerator           mapEnum;

       ;

       if (!emailPrimary)

       {

           throw warning("Email invalide");

       }

       if (parameters.EmailNotification == NoYes::No)

       {

           return;

       }

       if (emailParameters.SMTPRelayServerName)

           relayServer = emailParameters.SMTPRelayServerName;

       else

           relayServer = emailParameters.SMTPServerIPAddress;

       portNumber = emailParameters.SMTPPortNumber;

       userName = emailParameters.SMTPUserName;

       password = SysEmailParameters::password();

       subject = strFmt("TESTMAIL: %1", mwoId);

       body = notes;

       CodeAccessPermission::revertAssert();

       try

       {

           interopPermission = new InteropPermission(InteropKind::ComInterop);

           interopPermission.assert();

           mailer = new SysMailerNet();

           mailer.SMTPRelayServer(relayServer,portNumber,userName,password, false);

           mailer.fromAddress(userName);

           mailer.tos().add(emailPrimary);

           mapEnum = emailMap.getEnumerator();

           while (mapEnum.moveNext())

           {

               mailer.ccs().add(mapEnum.currentValue());

           }

           mailer.subject(subject);

           mailer.htmlBody(body);

           mailer.enableSsl(true);

           mailer.sendMail();

           CodeAccessPermission::revertAssert();

       }

       catch (Exception::CLRError)

       {

           e = ClrInterop::getLastException();

           while (e)

           {

               info(e.get_Message());

               e = e.get_InnerException();

           }

           CodeAccessPermission::revertAssert();

       }

    }

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,253 Super User 2024 Season 2 on at
    RE: Emails Notification problems

    Hi HEL

    In addition, have you verified the form with Email sending status if they are pending or in a failed state? If it is failed, it might be caused by "spam" policies on the Exchange server or Anti-virus scanners. In that case, you can set a retry mechanism in the email settings. See also the documentation: docs.microsoft.com/.../configure-email-functionality-in-microsoft-dynamics-ax

  • Ludwig Reinhard Profile Picture
    Ludwig Reinhard Microsoft Employee on at
    RE: Emails Notification problems

    Hello HEL,

    Can you please provide us more information on how you send the emails, where and how they were triggered and what you mean in case 3 by receiving a single email? Also, are these workflow related emails or others? Is this functionality related to a standard feature or something modified, etc.?

    Many thanks,

    Ludwig

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans