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)

How to send a auto email based on customer

(0) ShareShare
ReportReport
Posted on by

Hi friends,

please tell me how to send a auto email based on different customer using job queue in nav 2016.

thank you

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    Use Mail codeunit from NAV for creating the mail message, write your process (codeunit) that loops through customers, create the message and send the email. After creating the final process in NAV, you can schedule it via job queue.

    Start from here:

    community.dynamics.com/.../microsoft-dynamics-nav-2017-email-from-nav-part-1

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    Can you please elaborate your requirement are you planning to send email only for specific customers? If so you need to add some field on the customer to identify which customer or using any of the existing field like Customer Posting Group and then create a codeunit to loop through those customers and create email and send to them. Check Codeunit 10145 for example of sending email

  • Community Member Profile Picture
    on at

    Hi Suresh

    Thank you for reply  i want to send a report automatically using job queue  based on given customer id in my form and  report need to get filter based on chosen customer id in form.

    7318.job-queue.png

    this is job queue.

    7318.job-queue.png

    Thank you

  • Suggested answer
    CDsilva Profile Picture
    4,188 on at
  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    What errors are you facing? Does your codeunit has that logic placed to filter the customer on the report and use the email id ? Send us the code you have in the codeunit.

  • Community Member Profile Picture
    on at

    Hi suresh,

    this is my code

    PdfDocPath :='ABC.pdf';

    pdf2 := 'ABS.pdf';

    PATH2 :=TEMPORARYPATH+PdfDocPath;

    Path := TEMPORARYPATH+pdf2;

    CLEAR(ABC); // ABC is a Report 50088

    ABC.USEREQUESTPAGE(FALSE);  

            //// for filteration

    IF NOT ABC.SAVEASPDF(Path) THEN

    ERROR('PDF Creating Failed!\\ERROR:\\' + GETLASTERRORTEXT);

    //SMTP.CreateMessage('Jonas Wood','ashwini.e@sharpsyssoft.com','','Outstanding Amount','',TRUE) ;

    //try

    usersetuptable.RESET;

    useremail.RESET;

     REPEAT

     IF useremail.Branch = 'BGL' THEN BEGIN

        usersetuptable.SETRANGE("User ID",useremail.Branch);

         IF usersetuptable.FINDSET THEN

           Mail1 := usersetuptable."E-Mail";

        usersetuptable.SETRANGE("User ID",useremail."Sales To");

         IF usersetuptable.FINDSET THEN

           SalesTo:= usersetuptable."E-Mail";

         MESSAGE('%1',SalesTo);

        usersetuptable.SETRANGE("User ID",useremail."Sales CC");

         IF usersetuptable.FINDSET THEN

            SalesCC := usersetuptable."E-Mail";

           MESSAGE('%1',SalesCC);

        usersetuptable.SETRANGE("User ID",useremail."Sales BCC");

         IF usersetuptable.FINDSET THEN

           SalesBCC := usersetuptable."E-Mail";

          MESSAGE('%1',SalesBCC);

        usersetuptable.SETRANGE("User ID",useremail."Purchase To");

           IF usersetuptable.FINDSET THEN

           PurchaseTo := usersetuptable."E-Mail";

            MESSAGE('%1',PurchaseTo);

        usersetuptable.SETRANGE("User ID",useremail."Purchase CC");

           IF usersetuptable.FINDSET THEN

           PurchaseCC := usersetuptable."E-Mail";

         MESSAGE('%1',PurchaseCC);

        usersetuptable.SETRANGE("User ID",useremail."Purchase BCC");

           IF usersetuptable.FINDSET THEN

           PurchaseBCC := usersetuptable."E-Mail";

            MESSAGE('%1',PurchaseBCC);

        usersetuptable.SETRANGE("User ID",useremail."Finance To");

            IF usersetuptable.FINDSET THEN

           FinanceTo := usersetuptable."E-Mail";

             MESSAGE('%1',FinanceTo);

       usersetuptable.SETRANGE("User ID",useremail."Finance CC");

            IF usersetuptable.FINDSET THEN

           FinanceCC := usersetuptable."E-Mail";

             MESSAGE('%1',FinanceCC);

       usersetuptable.SETRANGE("User ID",useremail."Finance BCC");

            IF usersetuptable.FINDSET THEN

           FinanceBCC := usersetuptable."E-Mail";

             MESSAGE('%1',FinanceBCC);

             END;

          SMTP.CreateMessage('jonas Wood','ashwini.e@sharpsyssoft.com','','outstanding amount','',TRUE);

    //BGL

          IF SalesTo <> '' THEN

           BEGIN

          SMTP.AddTo(SalesTo);

           END;

          IF SalesCC <> '' THEN  BEGIN

         SMTP.AddCC(SalesCC);

           END;

         IF SalesBCC <> '' THEN  BEGIN

         SMTP.AddBCC(SalesBCC);

           END;

         IF PurchaseTo <> '' THEN  BEGIN

         SMTP.AddTo(PurchaseTo);

          END;

         IF PurchaseCC <> '' THEN  BEGIN

         SMTP.AddCC(PurchaseCC);

          END;

         IF PurchaseBCC <> '' THEN  BEGIN

         SMTP.AddBCC(PurchaseBCC);

           END;

         IF FinanceTo <> '' THEN  BEGIN

         SMTP.AddTo(FinanceTo);

           END;

         IF FinanceCC <> '' THEN  BEGIN

         SMTP.AddCC(FinanceCC);

           END;

         IF FinanceBCC <> '' THEN  BEGIN

         SMTP.AddBCC(FinanceBCC);

           END;

    UNTIL useremail.NEXT =0;

    SMTP.AppendBody('Dear Sir / Madam,');

    SMTP.AppendBody('<br><br>');

    SMTP.AppendBody('Please find the Customer Outstading Amount in PDF Format:');

    SMTP.AppendBody('<br><br>');

    SMTP.AppendBody('Regards');

    SMTP.AppendBody('<br>');

    SMTP.AppendBody('Company Accounts Departments ');

    SMTP.AddAttachment(Path,PdfDocPath);

    SMTP.AddAttachment(PATH2,pdf2);

    SMTP.Send;

    MESSAGE('Mail Sended');

    Thank you

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)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans