Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Users Mail

Posted on by Microsoft Employee

Hi friends,

i want to send a mail from smtp mail setup the main thing is i need to take a mail id from user setup table

PdfDocPath :='ABC.pdf';

Path := 'C:\\Temp'+PdfDocPath; // Directory + Path

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) ;

SMTP.AddCC('ashwini.e@sharpsyssoft.com');

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.Send;

this is my code please tell me how to i take the email id from use setup table based on the condition.

Thank you

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Users Mail

    Hi mohana

    Thank You for reply

    Please tell me how to take the text value automatically using cal code need to use that in

    my code then i can get the users mail id easily because the users will differ for purchase and sales and finance im taking the users in user setup table so i can not define for particular users mail id thats what i need to fetch user  data in text  automatically and send the mail based on the data

    this is my code

    PdfDocPath :='ABC.pdf';

    Path := 'C:\\Temp'+PdfDocPath; // Directory + Path

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

    ABC.USEREQUESTPAGE(FALSE); //// for filteration

    IF NOT ABC.SAVEASPDF(Path) THEN

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

    //here i need to add that code for retrieve the user data automatically using text box

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

    SMTP.AddCC('ashwini.e@sharpsyssoft.com');

    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.Send;

    Please help me on this one .

    Thank you

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Users Mail

    as I said in previous post, you need to repeat through all records in table and select the Purchase field and use it in sending mail.

    use table.Purchase in mail to section

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Users Mail

    Hi Mohana

    Thank You for reply

    i need to take the text box data s who i choose the users in text box then only i can sen the mail in any situation(if i changed the user name also i can send the mail )multiple user i can sen the mail .

    5873.utuert.png

    Thank you

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Users Mail

    you need to repeat through all records in table and send mail to sales branch people using sales field and same continues.

    if I am wrong then please provide the detailed requirement when and from which screen do you want to send mail etc.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Users Mail

    Hi Mohana

    Thank You for reply

    i need to send a mail based on the branch name for each branch i having three types of department

    Sales,purchase,finance i will choose the users for based on the department so need to send a mail for user which i will select in sales ,purchase,finance

    utuert.png

    i dont know how to take the user email id against users (sales,purchase,finance) in each department users will change so please help me on this one .

    Thank you 

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Users Mail

    you can use

    usersetup.get(<user id for which you want to send mail>);

    and use usersetup."E-Mail" in code where ever you want.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans