Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

I want to add same email id for all customer in Customer card and remove by default email id in NAV 2016

Posted on by 133

Can you please help me to solve this .

pastedimage1684215194522v1.png

  • AjayPandey Profile Picture
    AjayPandey 133 on at
    RE: I want to add same email id for all customer in Customer card and remove by default email id in NAV 2016

    Hi Nitin Can you please help me my logic is that if custledgentry found then email sent else skip

  • AjayPandey Profile Picture
    AjayPandey 133 on at
    RE: I want to add same email id for all customer in Customer card and remove by default email id in NAV 2016

    Hi Nitin again I need your help in this code o want to sent mail to those customer who have record if record is not available then mail will not sent , if record is found then mail will sent to the customer.

    mention below is the code for sent mail to customer.

    Documentation()

    OnRun()

    SentMailtoCust(CustNo : Code[20])

    SMTPSetup.GET;

    Customer.GET(CustNo);

       Customer.TESTFIELD("E-Mail");

       IF CustLedgEntry.fin

       SMTPMail.CreateMessage('',SMTPSetup."User ID",Customer."E-Mail",'Test1','',TRUE);

       IF SalesPerson."E-Mail"<>'' THEN

         SMTPMail.AddCC(SalesPerson."E-Mail");

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

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

           SMTPMail.AppendBody('Please find Pending Payments List.');

           SMTPMail.AppendBody('<br><Br>');

           SMTPMail.AppendBody('<table border="1">');

           SMTPMail.AppendBody('<tr>');

           SMTPMail.AppendBody('<th>Invoice No.</th>');

           SMTPMail.AppendBody('<th>Invoice Date</th>');

           SMTPMail.AppendBody('<th>Due Date</th>');

           SMTPMail.AppendBody('<th>Invoice Amount</th>');

           SMTPMail.AppendBody('<th>Balance Amount</th>');

           SMTPMail.AppendBody('</tr>');

           CustLedgEntry.SETCURRENTKEY("Customer No.",Open,Positive,"Due Date","Currency Code");

           CustLedgEntry.SETRANGE(CustLedgEntry."Customer No.",CustNo);

           CustLedgEntry.SETRANGE(Open,TRUE);

           CustLedgEntry.SETRANGE(CustLedgEntry."Document Type",CustLedgEntry."Document Type"::Invoice);

          IF CustLedgEntry.FINDFIRST THEN

           REPEAT

               CustLedgEntry.CALCFIELDS("Amount (LCY)");

               CustLedgEntry.CALCFIELDS("Remaining Amt. (LCY)");

               SMTPMail.AppendBody('<tr>');

               SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Document No.")+'</td>');

               SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Posting Date")+'</td>');

               SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Due Date")+'</td>');

               SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Amount (LCY)")+'</td>');

               SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Remaining Amt. (LCY)")+'</td>');

               SMTPMail.AppendBody('</tr>');

         UNTIL(CustLedgEntry.NEXT=0);

           SMTPMail.AppendBody('</table>');

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

           SMTPMail.AppendBody('Regards,');

           SMTPMail.AppendBody('<br>');

           SMTPMail.AppendBody('Ajay Pandey');

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

           SMTPMail.AppendBody('<HR>');

           SMTPMail.AppendBody('This is a system generated mail. Please do not reply to this email ID.');

    SMTPMail.Send;

  • AjayPandey Profile Picture
    AjayPandey 133 on at
    RE: I want to add same email id for all customer in Customer card and remove by default email id in NAV 2016

    Thanks Nitin now work properly

  • AjayPandey Profile Picture
    AjayPandey 133 on at
    RE: I want to add same email id for all customer in Customer card and remove by default email id in NAV 2016

    when i go through this code it can sent only one record to n times

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: I want to add same email id for all customer in Customer card and remove by default email id in NAV 2016

    I have tried with your code, and does not looks good to me, so I tried this way may be you need to give more attention in this code as well.

    LOCAL SentMailtoCust()
    SentMailtoCust(CustNo : Code[20])
    SMTPSetup.GET;
    IF Customer.FINDSET THEN
    REPEAT
      Customer.TESTFIELD("E-Mail");
      SalesPerson.GET(Customer."Salesperson Code");
      SMTPMail.CreateMessage('',SMTPSetup."User ID",Customer."E-Mail",'Test1','',TRUE);
      IF SalesPerson."E-Mail"<>'' THEN
        SMTPMail.AddCC(SalesPerson."E-Mail");
    
        SMTPMail.AppendBody('Dear Sir / Madam,');
        SMTPMail.AppendBody('

    '); SMTPMail.AppendBody('Please find Pending Payments List.'); SMTPMail.AppendBody('

    '); SMTPMail.AppendBody(''); SMTPMail.AppendBody(''); SMTPMail.AppendBody(''); SMTPMail.AppendBody(''); SMTPMail.AppendBody(''); SMTPMail.AppendBody(''); SMTPMail.AppendBody(''); SMTPMail.AppendBody(''); CustLedgEntry.SETCURRENTKEY("Customer No.",Open,Positive,"Due Date","Currency Code"); CustLedgEntry.SETRANGE(CustLedgEntry."Customer No.",CustNo); CustLedgEntry.SETRANGE(Open,TRUE); CustLedgEntry.SETRANGE("Due Date",'
  • AjayPandey Profile Picture
    AjayPandey 133 on at
    RE: I want to add same email id for all customer in Customer card and remove by default email id in NAV 2016

    How to sent multiple record at a time.

    I have already done this for single record send mail .

    can you please help to resolve it.

    but when i apply loop for send more than one record it can't work below are the CodeUnit for  sent mail:-

    Documentation()

    OnRun()

    SentMailtoCust(CustNo : Code[20])

    SMTPSetup.GET;

    IF Customer.FINDSET THEN

    REPEAT

    UNTIL(Customer.NEXT=0);

    Customer.TESTFIELD("E-Mail");

    SMTPMail.CreateMessage('',SMTPSetup."User ID",Customer."E-Mail",'Test1','',TRUE);

    IF SalesPerson."E-Mail"<>'' THEN

    SMTPMail.AddCC(SalesPerson."E-Mail");

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

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

    SMTPMail.AppendBody('Please find Pending Payments List.');

    SMTPMail.AppendBody('<br><Br>');

    SMTPMail.AppendBody('<table border="1">');

    SMTPMail.AppendBody('<tr>');

    SMTPMail.AppendBody('<th>Invoice No.</th>');

    SMTPMail.AppendBody('<th>Invoice Date</th>');

    SMTPMail.AppendBody('<th>Due Date</th>');

    SMTPMail.AppendBody('<th>Invoice Amount</th>');

    SMTPMail.AppendBody('<th>Balance Amount</th>');

    SMTPMail.AppendBody('</tr>');

    SalesPerson.GET(Customer."Salesperson Code");

    CustLedgEntry.SETCURRENTKEY("Customer No.",Open,Positive,"Due Date","Currency Code");

    CustLedgEntry.SETRANGE(CustLedgEntry."Customer No.",CustNo);

    CustLedgEntry.SETRANGE(Open,TRUE);

    CustLedgEntry.SETRANGE(CustLedgEntry."Document Type",CustLedgEntry."Document Type"::Invoice);

    IF CustLedgEntry.FINDFIRST THEN

    REPEAT

    CustLedgEntry.CALCFIELDS("Amount (LCY)");

    CustLedgEntry.CALCFIELDS("Remaining Amt. (LCY)");

    SMTPMail.AppendBody('<tr>');

    SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Document No.")+'</td>');

    SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Posting Date")+'</td>');

    SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Due Date")+'</td>');

    SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Amount (LCY)")+'</td>');

    SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Remaining Amt. (LCY)")+'</td>');

    SMTPMail.AppendBody('</tr>');

    UNTIL(CustLedgEntry.NEXT=0);

    SMTPMail.AppendBody('</table>');

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

    SMTPMail.AppendBody('Regards,');

    SMTPMail.AppendBody('<br>');

    SMTPMail.AppendBody('Ajay Pandey');

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

    SMTPMail.AppendBody('<HR>');

    SMTPMail.AppendBody('This is a system generated mail. Please do not reply to this email ID.');

    SMTPMail.Send;

    SendTestMailtoCust(CNo : Code[20])

    IF Cust.FINDSET THEN

    REPEAT

    UNTIL(Cust.NEXT=0);

    SMTPSetup.GET;

    SMTPMail.Send;

    SendMailtoCustWithAttachment(CustNo : Code[20])

    SMTPSetup.GET;

    IF Customer.FINDSET THEN

    REPEAT

    UNTIL(Customer.NEXT=0);

    Customer.TESTFIELD("E-Mail");

    SalesPerson.GET(Customer."Salesperson Code");

    IF SalesPerson."E-Mail" <> '' THEN

    SMTPMail.AddCC(SalesPerson."E-Mail");

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

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

    SMTPMail.AppendBody('Please find Attached Sales Statistics.');

    SMTPMail.AppendBody('<br><Br>');

    SMTPMail.AppendBody('Regards,');

    SMTPMail.AppendBody('<br>');

    SMTPMail.AppendBody('Saurav Dhyani');

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

    SMTPMail.AppendBody('<HR>');

    SMTPMail.AppendBody('This is a system generated mail. Please do not reply to this email ID.');

    SMTPMail.Send;

  • AjayPandey Profile Picture
    AjayPandey 133 on at
    RE: I want to add same email id for all customer in Customer card and remove by default email id in NAV 2016

    Thank You so much Mr Nitin.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: I want to add same email id for all customer in Customer card and remove by default email id in NAV 2016

    Please visit this link to have more idea about the report

    www.youtube.com/watch

  • AjayPandey Profile Picture
    AjayPandey 133 on at
    RE: I want to add same email id for all customer in Customer card and remove by default email id in NAV 2016

    Dear Nitin,

    I think first i need to

    create one new report

    data source- customer

    create variable name-email

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: I want to add same email id for all customer in Customer card and remove by default email id in NAV 2016

    Two options, eight with Config. package, or write a custom report processing only report to update the email address on all customer card.

    Thanks.

  • 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!

    Community AMA December 12th

    Join us as we continue to demystify the Dynamics 365 Contact Center

    Leaderboard

    #1
    André Arnaud de Calavon Profile Picture

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

    #2
    Martin Dráb Profile Picture

    Martin Dráb 230,149 Most Valuable Professional

    #3
    nmaenpaa Profile Picture

    nmaenpaa 101,156

    Leaderboard

    Featured topics

    Product updates

    Dynamics 365 release plans
    Invoice No.Invoice DateDue DateInvoice AmountBalance Amount