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 NAV (Archived)

Check to send mail NAV

(0) ShareShare
ReportReport
Posted on by

Hello world,

i want to create a CodeUnit to check 2 fields (Date) if they are empty, dont do anything, if not add 30Days and check if its >= the previous Field. after comparing send a mail message

Thanks for helping me

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    what is your question now?

  • Community Member Profile Picture
    on at

    thank you for responding.

    my question is , how can i do that ??

  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    Did you try anything? Please provide what did you try and what issues are you facing.

  • Community Member Profile Picture
    on at

    i created a Function (CheckToSendMail) and i put this :

    LOCAL CheckSendToMail()

    Employee.FINDFIRST;

    REPEAT

     IF

       Employee."Echéance Passeport 1" <= CALCDATE('<TODAY+30D-1>')

       THEN EXIT

       ELSE

       SMTPMail.Send ;

     IF

       Employee."Echéance Passeport 2" <= CALCDATE('<today+30D>')

       THEN EXIT

       ELSE

       SMTPMail.Send;

    UNTIL Employee.NEXT =0;

  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    check this link about CALCDATE

    msdn.microsoft.com/.../dd301368(v=nav.90).aspx

  • Suggested answer
    4BzSoftware Profile Picture
    6,073 on at

    Hi Zakariia Bou,

    It is same as a request from my customers. If Date of Expiry of one of two passports is going to be expired within 30 days, send an email to HR Staff to notify them.

    LOCAL CheckSendToMail()

    IF (Employee.FINDFIRST) THEN

      REPEAT

        IF (Employee."Echéance Passeport 1" IN [TODAY..CALCDATE('<+30D>', TODAY)]) THEN

          SMTPMail.Send

        ELSE IF (Employee."Echéance Passeport 2" IN [TODAY..CALCDATE('<+30D>', TODAY)]) THEN

          SMTPMail.Send;

      UNTIL (Employee.NEXT = 0);

  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    Always use FINDSET for REPEAT UNTIL

  • Community Member Profile Picture
    on at

    Thank you so much Khoa Nguyen

    I appreciate that

  • 4BzSoftware Profile Picture
    6,073 on at

    You're welcome!

    Have a nice day to all :-)

  • Suggested answer
    CDsilva Profile Picture
    4,188 on at

    Hi

    You can refer my blog, in the blog the code checks for the visa expiry date, if visa expires in a month then a  email is send to the HR. you can code on similar lines

    http://www.cloudfronts.com/run-batch-check-visa-expiry-date-employees-send-email-visa-expires-month-dynamics-nav/

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 NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans