Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Send mail in ax with body,birth day greeting mail

Posted on by Microsoft Employee

Dear Friends ,

I need to send mail from AX,Birth day Greeting mail to the employees.

How can I develop below template and send as mail.

BirthDayGreeting.png

*This post is locked for comments

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Send mail in ax with body,birth day greeting mail

    Creating a batch job is one thing, and you can find plenty of help for that from the internet and from the community forums.

    But here's how to get all DirPerson records who have birthday today:

        DirPerson dirPerson;
        date todaysDate = systemDateGet();
        Day birthDay = dayOfMth(todaysDate);
        MonthsOfYear birthMonth = mthOfYr(todaysDate);
        YearBase birthYear = year(todaysDate);
        
        while select dirPerson
            where dirPerson.BirthDay == birthDay
                && dirPerson.BirthMonth == birthMonth
                && dirPerson.BirthYear == birthYear
        {
            info(dirPerson.name);
        }


  • Zeeshan Adeel Profile Picture
    Zeeshan Adeel 335 on at
    RE: Send mail in ax with body,birth day greeting mail

    kindly send me Batch Job that checks for birthday each day.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Send mail in ax with body,birth day greeting mail

    BirthDay_5F00_HTML.png

    Hi Friends,

    I am able to send the Birthday greeting now with the help of Email Template.

    1.I created one email-template

    2.Added my HTML Image

    BirthDay_5F00_HTML.png

    3.I kept my jpg file at email parameters form,Folder location,I have given permissions to everyone for below folder.

    JPG_5F00_Location.png

    4.Code To call this jpg file as HTML and pass as body of mail.

    message = SysEmailMessageTable::find('Reminder', 'en-us');
    mappings = new Map(Types::Container,Types::Container);
    ret = WebLet::weblets2Html4Help(SysEmailMessage::stringExpand(message.Mail, mappings), '');

    Now I am able to see my birthday greeting at gmail and Client outlook.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Send mail in ax with body,birth day greeting mail

    PictureLibraryInSharePoint.pngPictureLibraryInSharePoint.png

    MailToClient.pngDear Crispin,

    I saved my image at Sharepoint 2007 Picture library and that URL i am passing in img tag

       txt ='<html><body><img src="mu-prodmsd-01/.../HBD.jpg"></body></html>';

    reciepient user is also given permission for the file in share Point still in mail image is not coming

    Please check my screen shots from share Point(which client uses for Enterprise Portal as well)

    below is my compelet code

    static void pwc_SendMailTest(Args _args)
    {


    PwC_ParseEmailTemplate parseEmailTemplate, parseEmailTemplate1, parseEmailTemplate2;
    container parseEmailTemplate_1;
    HRMParameters hrmParameters;
    Email emplMail,mgrMail, fromEmail;
    SysUserInfo sysUserInfo;
    UserInfo userInfo;
    str finalTo,finalCC,finalToAct;
    Empltable empltable1,empltable2;
    DirPartyTable dirpartytable1,dirpartytable2;
    PwC_EmailTemplateParameter pwc_emailparm;
    Date CurrDate = systemdateget();
    PwC_employeeInfo txt,txt1, txt2, txt3;
    str emailmessage, EmplId1;
    HRPPartyPositionTableRelationShip hrpPartyPositionTableRelationShip;
    HRMPartyEmployeeRelationship hrmPartyEmployeeRelationship;
    PwC_EmplAdditionalFields pwc_EmplAdditionalFields;
    //PwC_EmplTableDayMon t;
    ;

    hrmParameters = HRMParameters::find();

    parseEmailTemplate1 = new PwC_parseEmailTemplate(hrmParameters.PwC_EmailSetupTemplateId[20]);
    txt1 = parseEmailTemplate1.getBody();

    parseEmailTemplate2 = new PwC_parseEmailTemplate(hrmParameters.PwC_EmailSetupTemplateId[2]);
    txt2 = parseEmailTemplate2.getBody();

    // while select * from empltable1

    // where empltable1.EmplId == '1008'
    //{
    // if(Mthofyr(empltable1.BirthDate)==mthofyr(Currdate)&&Dayofmth(empltable1.BirthDate)==dayofmth(CurrDate))
    //{
    select firstonly dirpartytable1
    where dirpartytable1.PartyId==empltable1.PartyId;
    select firstonly hrpPartyPositionTableRelationShip
    where hrpPartyPositionTableRelationShip.Reference == emplTable1.EmplId;
    select firstonly hrmPartyEmployeeRelationship
    where hrmPartyEmployeeRelationship.EmplId == emplTable1.EmplId;
    select firstonly pwc_EmplAdditionalFields
    where pwc_EmplAdditionalFields.EmplId == emplTable1.EmplId;

    parseEmailTemplate = new PwC_parseEmailTemplate(hrmParameters.PwC_EmailSetupTemplateId[21],[empltable1]);//, dirpartytable1, hrpPartyPositionTableRelationShip, hrmPartyEmployeeRelationship]);

    // info(empltable1.EmplId);
    // info(dirpartytable1.Name);

    txt += parseEmailTemplate.getBody();

    txt = '<html><body > &nbsp <table style="border:1px solid black;" >'+
    '<tr> <td style="background-color:#FFF5EE"><i><font size="5" color="brown"><center><b>Wishing for a birthday that unfolds beautiful surprises'+
    '</center></b></font></i><br/>'+
    ' <font size="5" color="brown"><b><i><center>and lots of happiness for you!</b></center></font></br></br> <font size="5" color="blue"><center><b><i>Have a day as special as you are!</center></font></br>'+
    '</br><font size="4" color="red"><b><center><i>Happy Birthday to you!!</center></b></font></br></br><p>&nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp'+
    '&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp <b>Priya P</b> '+
    '&nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp <b>Poovendra Kumar V</b> &nbsp&nbsp&nbsp'+
    '&nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp<b> Chandrakant Salunke</b>'+

    '<BR />&nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp Facilities Management - Site &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp Facilities Management - Site'+
    '&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp&nbsp Facilities Management - Site</br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp'+
    ' &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Chennai'+
    '&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Bangalore'+
    '&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp'+
    '&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Mumbai</p>'+
    '<br> &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp<b> Ashok Kumar H K</b>'+
    '&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp<b> Ravindra Singh </b>'+
    '<br /> &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Facilities Management - Site'+
    '&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Finance'+
    '<BR />&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Bangalore'+
    '&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Gurgaon</td> </tr>'+
    '<tr style="background-color:#AFEEEE" > &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp'+
    '&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Human Resources </tr></table></body></html>'
    ;

    txt ='<html><body><img src="http://mu-prodmsd-01:24319/PictureLibraryForShare/HBD.jpg"></body></html>';

    //ead more: https://html.com/attributes/table-bordercolor/#ixzz5YpbbzXCE


    if(parseEmailTemplate.getToList())
    finalToAct = SysUserInfo::find(SysCompanyUserInfo::emplId2UserId(emplTable1.EmplID)).Email;
    // finalto = 'singh.k.sanjay@in.pwc.com';
    finalto = 'sanjay.1816@gmail.com';
    finalto = 'Sudhirkant.Panda@in.knightfrank.com';
    // finalto=parseEmailTemplate.getToList();
    if(parseEmailTemplate.getCCAddress())
    finalCC = parseEmailTemplate.getCCAddress();

    txt3 = txt;

    fromemail = 'msax@in.knightfrank.com';

    if (finalto)
    try
    {
    Global::pwCSendMail_kes(fromemail, [finalto], 'Test Mail(Please Ignore),Birthday Greetings', txt3);
    info('Mail Sent');
    }
    catch (Exception::CLRError)
    {
    info ("Failed to Send Email some Error occure");
    }
    // }
    // }


    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Send mail in ax with body,birth day greeting mail

    Hi,

    Outlook Scenario Client is already using,

     below is their feedback,  

    According to my understanding, Sudhir is doing the same manually(outlook), which is not acceptable to business and they wanted an automated process from master (Employee Master)data.

  • Crispin John Augustine Profile Picture
    Crispin John Augustine 37,081 on at
    RE: Send mail in ax with body,birth day greeting mail

    .....file:///C:/Users/sushri/Desktop/HBD.JPEG.... is a local path.

    Batch will obviously not find this.. You have to specify a Network path here.

    And here is an example community.dynamics.com/.../code-to-send-image-in-email-using-axapta-2012

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Send mail in ax with body,birth day greeting mail

    body = <html><body bgcolor="red"><i><font size="3" color="brown"><center>Wishing for a birthday that unfolds beautiful surprises</center></font></i><br/>'+
    ' <font size="3" color="brown"><center>and lots of happiness for you!</center></font></br></br> <font size="3" color="blue"><center>Have a day as special as you are!</center></font></br>'+
    '</br><IMG src="file:///C:/Users/sushri/Desktop/HBD.JPEG" width=50 height=50 ></body></html>';

    This is the below body comes in email.But Image is not coming 

    Body.png

  • guk1964 Profile Picture
    guk1964 10,877 on at
    RE: Send mail in ax with body,birth day greeting mail

    I would rather not do this in my erp system, there are other options e.g.

    https://flow.microsoft.com/en-us/galleries/public/templates/b6e38eb5fda442069ea2acf299a31d3e/send-a-happy-birthday-email-to-employees-on-their-birthday/ This uses a SharePoint list.

    You can also use a word template with some bookmarks or use some VBA code and Outlook using an Outlook template.

     For a semi manual process that is easy to set up when f you have everyone's birthday in your calendar then you will also get reminders. Your IT admin will in any case add new users to your email system so its not a lot of extra work to also add their birthday to Outlook - then it will recur every year,    

    1. Create an email template: Compose template email> choose File>Save As>Save as type>Outlook Template>choose name and click Save to save template locally.
    2. Create new email from template: On the Home tab, in the New group, click New Items, point to More Items, and then Choose Form> In the Choose Form dialog box, in Look In, click User Templates in File System.
    3. As you may send it to different individuals, you may need to change their names in the email.
    4. Choose the specific date you want to send to these and use the delay sending function, these messages will be held in your outbox until the defined day arrives so you can do this task e.g. once a month.

  • Suggested answer
    Crispin John Augustine Profile Picture
    Crispin John Augustine 37,081 on at
    RE: Send mail in ax with body,birth day greeting mail

    Quite a few simple steps:

    * A Batch Job that checks for birthday each day,

    * append the Image using html

    mailer.htmlBody(body); as you will find in this example  community.dynamics.com/.../sending-email-using-x-code-dynamics-ax-2012

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans