Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

DueDate

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

hi experts,

I want to send a mail if duedate is greater 5 days of today 

duedate := 25/4/2018

DuedateCalculation := calcdate(>=+5D, duedate)

TodayDate := TODAY;

IF DuedateCalculation  = >Today then

SMTP.AppendBody(Text009);
SMTP.AppendBody(Text010);
SMTP.AppendBody(Text011+' '+COPYSTR(customer."No.",1,50)+','+' '+COPYSTR(customer.Name,1,50)+ ' '+Text012+FORMAT(dueamounts)+Text0017);
SMTP.AppendBody(Text010);
SMTP.AppendBody(Text013);
SMTP.AppendBody(Text014);
SMTP.AppendBody(Text015);
SMTP.AddAttachment(path,PdfDocPath);
SMTP.AddAttachment(path2,pdf2);
SMTP.Send;

Its not working please tell me i want to send a email expired due date (after 5 date of due date i need to send a mail ) i dont know how to calculate the date. please give any solution.

Thank you

*This post is locked for comments

  • Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: DueDate

    Hi Ashwini.123,

    Perhaps you can try this code as well

    DayValue := DATE2DWY(TODAY,1);

    IF DayValue = 1 THEN BEGIN //ON MONDAY

    //Do the Sunday Task

    //Do the Monday Task

    END;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: DueDate

    Hi Olister,

    Thank you for your reply i got solution based on your instruction and Thank you for all

  • Suggested answer
    CDsilva Profile Picture
    CDsilva 4,184 on at
    RE: DueDate

    Hi,

    Then you can check if yesterday was sunday.

    today date:=TODAY -1D;

    then check if today date is sunday

    Follow the article to get week day

    docs.microsoft.com/.../date2dwy-function--date-

    DayOfWeek := DATE2DWY(today date, 1);

    if DayOfWeek =7  then //sunday

    sendmail

    You can also check my blog. Here I had written a job to check visa expiry date. If my visa expires next month then an email will be sent to the HR.

    https://chrisdsilvablog.wordpress.com/2017/11/14/how-to-setup-a-batch-to-run-daily-and-send-an-email-on-validation-of-a-field-in-microsoft-dynamics-nav/

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: DueDate

    Hi Chirs,

    My requirement is i need to send a auto email for expired due date(after 5 days of due date)

    Eg:

    //Saturday

    duedate := 3/05/2018

    NewDate = CALDATE('+5D',duedate )

    now  duedate := 8/05/2018

    if(duedate =today) the

    send;

    this condition is working fine, in our office  Sunday server will be off   email not sending

    that time sunday mail will not go

    //Sunday

    Duedate := 4/05/2018

    NewDate = CALDATE('+5D',duedate )

    Now duedate := 9/05/2018;

    if(duedate =today) the

    send;

    monday only my office will in open i have on the server on monday

    //Monday

    Duedate := 5/05/2018

    NewDate = CALDATE('+5D',duedate )

    Now duedate := 10/05/2018;

    if(duedate =today) the

    send;

    Mail will send for saturday but sunday  will be on off so i need to send mail on monday for sunday this time only i want add >5 from duedate ,monday date is :=10/05/2018  my sunday due date is duedate := 4/05/2018 so i need to add NewDate = CALDATE('>5D',duedate ) then only i can mail for sunday this date 10/05/2018 beacause my conditions

    if (today=duedate) then

    send;

    //Sunday

    Duedate := 4/05/2018

    NewDate = CALDATE('+5D',duedate )

    Now duedate := 9/05/2018;

    today date  := 10/05/2018

    if(duedate =today) this condition will not work because i need to take due amount >5 days to send mail for sunday beacause monday date is 10/05/2018 but sunday i add a 5 days  9/05/2018 its not working on monday greater than 5 days then only i can reach today of monday.

    Like this NewDate = CALDATE('>5D',duedate ) then only i can send mail for sunday on monday.

    Please i can not explain more please this level only i can explain please give any solution

    thank you

  • Verified answer
    Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: DueDate

    Hi Ashwini.123,

    I've a question regarding what exactly are you trying to do.

    1. On what event the mail should be sent for eg like an Action, Job

    if you want to send mail the after 5 or more days later of due date, then use the following code

    NewDate = CALCDATE('5D',DueDate);

    IF TODAY >= NewDate THEN BEGIN

    //SEND MAIL

    END;

    If still your requirement is not met,
    Please give an example scenario with TODAYS date, DueDate, EmailDate etc.

  • Suggested answer
    CDsilva Profile Picture
    CDsilva 4,184 on at
    RE: DueDate

    Hi ,

    you said "if due date is 02/5/2018 means this is comes under > 5 days from today date"

    today is 08/5/2018. How is 02/5/2018 greater than from today. Can you explain?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: DueDate

    Hi Chirs,

    Thank you for your reply this condition is working fine for after 5 days of due date

    After 5 days of DueDate -working

    if duedate is 3/05/2018 means its adding 5 days and total is 8/05/2018 so its working

    NewDate = CALDATE('5D',DueDate);

    today :=Today ;

    if(newDate = today) then

    smtp.send;

    Greater than 5 days not working

    if due date is 02/5/2018 means this is comes under > 5 days from today date for this only im trying to write a code

    NewDate = CALDATE('>5D',DueDate); --not working

    Thank you

  • Verified answer
    CDsilva Profile Picture
    CDsilva 4,184 on at
    RE: DueDate

    Hi Ashwini,

    you can try NewDate = CALDATE('5D',DueDate); //this will calculate duedate + 5 days

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: DueDate

    Hi Olister

    Thank you so much for your reply

    your above code i have tired unfortunately its not working please see my blow screen shot

    dueamount.png

    i want to send a mail after or greater than 5 days of expired due date  not after 5 days of TODAY date.

    Thank you

  • Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: DueDate

    Hi Ashwini.123,

    Considering that you want to send email to entries having DueDate >=5Days from TODAY  then use

    NewDate = CALDATE('5D',TODAY);

    IF DueDate >= NewDate THEN BEGIN

    //Your mailing code

    CLEAR(SMTPMail);

    SMTPMail.CreateMessage('',SMTPMailSetup."User ID",EmailID,'Value','',TRUE); //EmailID is recepient email address and Value is the Subject of the mail

    SMTP.AppendBody(Text009);

    SMTP.AppendBody(Text010);

    SMTP.AppendBody(Text011+' '+COPYSTR(customer."No.",1,50)+','+' '+COPYSTR(customer.Name,1,50)+ ' '+Text012+FORMAT(dueamounts)+Text0017);

    SMTP.AppendBody(Text010);

    SMTP.AppendBody(Text013);

    SMTP.AppendBody(Text014);

    SMTP.AppendBody(Text015);

    SMTP.AddAttachment(path,PdfDocPath);

    SMTP.AddAttachment(path2,pdf2);

    SMTP.Send;

    END;

    If the mail doesn't send please check the SMTP Mail Setup. Try by sending mail without the attachment first.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,401 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans