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 AX (Archived)

Convert html table code as normal Table with data in Outlook 2007

(0) ShareShare
ReportReport
Posted on by 223

Hi Friends,

   I am creating a html table and data at run time in AX 7 (D365) and sending as mail to outlook 2007.

I am receiving the mail as html code only, how to convert it as table in outlook?

I am receiving mail as below.

<Table border='2'><th>Item Code </th><th>Product Name </th>

<tr><td>P0002</td><td>Speaker Damping Foam</td></Table>

<tr><td>P0003</td><td>Speaker</td></Table>

Is there a way to see it as a table in outlook mail?

Regards

Martin.A

*This post is locked for comments

I have the same question (0)
  • Jie G Profile Picture
    on at

    Hi Martin,

    Have you sent the email in html format? You may try to use the setBody( ) method of SysMailerMessageBuilder.

    0028.1.PNG

    And you can send a html based email(with a table inserted in the email) to your mail box and right click the email and select "view source" in your Outlook 2007. Take it as an example to prepare your customized html table in AX.

  • martinarul Profile Picture
    223 on at

    Hi Ada Ding,

        I am not able to understand your suggestion. I am sending as html body only. When I seen that in Outlook mailbox I need to see as table. For that what should I do. Is there any option in outlook itself or can I convert while sending as mail in the x++ code itself?

    Thanks for spending you time..

    Regards

    Martin. A

  • martinarul Profile Picture
    223 on at

    Hi Sukrut,

      I am able to form html table at run time and send mail successfully. My problem is that when I send mail to outlook it is sent as html code only and not as a Table. I am not using Email Template as well. 

    Regards

    Martin. A

  • Verified answer
    Jie G Profile Picture
    on at

    Hi Martin,

    I have tested your html (but remove a </Table> in second line)via X++, and I can receive a table in  outlook 2017.

    776816.1.PNG

    And here is my code:

    class SendEmail
    {        
        /// <summary>
        /// Runs the class with the specified arguments.
        /// </summary>
        /// <param name = "_args">The specified arguments.</param>
        public static void main(Args _args)
        {
            SysMailerMessageBuilder mailer  = new SysMailerMessageBuilder();
            SysMailerSMTP           smtp    = new SysMailerSMTP();
            SMTPRelayServerName RelaySvrName = "192.***.**.**";
            SMTPPortNumber ptNumber = 25;
            SMTPUserName uName = "contoso\administrator";
            SMTPPassword psw = "*******";
            smtp.smtpRelayServer(RelaySvrName, ptNumber, uName,psw);
            str body = @"<Table border='2'><th>Item Code </th><th>Product Name </th><tr><td>P0002</td><td>Speaker Damping Foam</td><tr><td>P0003</td><td>Speaker</td></Table>";
            try
            {
                mailer.setSubject("AX7 - Sending e-mail through x++");
                mailer.setFrom("abc@edf.com");
                mailer.setBody(body, true);
                mailer.addTo("***@***.com");
                smtp.sendNonInteractive(mailer.getMessage());
            }
            catch(Exception::CLRError)
            {
                error(CLRInterop::getLastException().toString());
            }
        }
    
    }


  • martinarul Profile Picture
    223 on at

    Hi Ada Ding,

          Thank you a lot for the effort you took to explain. Now its working fine for me.

    The mistake I made was in the below line.

    mailer.setBody(body, true);

    Instead of passing true, I passed false.
    Now its working fine.

    Regards
    Martin. A

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 AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans