web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

cannot read message body of incoming email

(0) ShareShare
ReportReport
Posted on by 180

I am trying to read the email message portion of emails that are incoming to an email account via Dynamics AX 2012. I have created a job below for testing. I usually get back what looks like garbage for the message body while reading the subject, etc. works fine. I have tried to read as HTML and as Plain text. I know the email is html but when I read as HTML I get a "" message returned. Thanks.

NAME:mBlob1
VALUE:
TYPE:str

NAME: mBlob3
VALUE:PGh0bWw+DQo8aGVhZD4NCjxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PXV0Zi04Ij4NCjwvaGVhZD4NCjxib2R5Pg0KMS1hcHByb3ZlZCA8YnI+DQo8YnI+DQo8YnI+DQpTZW50IGZyb20gUHJvdG9uIE1haWwgbW9iaWxlPGJyPg0KPGJyPg0KPGJyPg0KPGJyPg0KLS0tLS0tLS0gT3JpZ2luYWwgTWVzc2FnZSAtLS0tLS0tLTxicj4NCk9uIEF1ZyAzLCAyMDIyLCAxMToyOCBBTSwgQXJ0aXNhbnMgUHJvb2YgJmx0OyBBcnRpc2Fuc0FYVGVzdEBhcnRpc2Fuc2luYy5jb20mZ3Q7IHdyb3RlOg0KPGJsb2NrcXVvdGUgY2xhc3M9InByb3Rvbm1haWxfcXVvdGUiPjxicj4NCjEtdGVzdA0KPGRpdj48L2Rpdj4NCjwvYmxvY2txdW90ZT4NCjwvYm9keT4NCjwvaHRtbD4NCg==
TYPE:str

 static void Job156Pop3Receive(Args _args)

{

    SysEmailAccount         sysEmailAccount;

    SysEmailMessageReadContent  SysEmailMessageReadContent  = SysEmailMessageReadContent::construct();

    SysEmailAccountList     sysEmailAccountList = SysEmailAccountList::construct();

    SysEmailReader          sysEmailReader      = SysEmailReader::construct();

    SysEmailMessageReadList sysEmailMessageReadList;

    SysEmailMessageRead     sysEmailMessageRead;

    //Art156Table1            Art156Table1;

 

    //SysEmailMessageReadContent  SysEmailMessageReadContent;

    SysEmailReadHtmlBody mBlob1;

    SysEmailReadHtmlBody mBlob2;

    SysEmailReadHtmlBody mBlob3;

    SysEmailReadHtmlBody mBlob4;

   

    sysEmailAccount = SysEmailAccount::newAccount('xxxxx.xxxx.com', 'xxxxx@xxxx.com', 'xxxxxxxxxxxx', 995true);

 

    // Add the account to a list of accounts to be checked

    sysEmailAccountList.add(sysEmailAccount);

 

    // Get a list of unread meassages

    sysEmailMessageReadList = sysEmailReader.getUnreadEmailMessages(sysEmailAccountList);

 

    // Loop over the list of unread mesages

    //while (sysEmailMessageReadList.moveNext())

    //x=0;

    sysEmailMessageReadList.reset();

    sysEmailMessageReadList.moveFirst();

    while (sysEmailMessageReadList.moveNext()) //while (x <= 1)

    {

        // Get the current message from the message loop

        sysEmailMessageRead = sysEmailMessageReadList.current();

 

        // Work with this message(show the subject line)

        info (sysEmailMessageRead.parmSubject());

         //current used 1

        mBlob1 = sysEmailMessageRead.parmHTMLBody();

        mBlob2 = sysEmailMessageRead.ArtHtml2Text(mBlob1);

        if (mBlob2)

        {

            info(strFmt("blob1: %1",mBlob1));

            info(strFmt("blob2: %1",mBlob2));

        }

         //current used 2

        mBlob3 = sysEmailMessageRead.parmBody();

        mBlob4 = sysEmailMessageRead.ArtHtml2Text(mBlob3);

        if (mBlob4)

        {

            info(strFmt("blob3: %1",mBlob3));

            //info(strFmt("blob4: %1",mBlob4));

        }

        info (sysEmailMessageRead.parmBody());

        print '';

    }

}

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    238,125 Most Valuable Professional on at

    What you get isn't garbage. This text:

    PGh0bWw DQo8aGVhZD4NCjxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PXV0Zi04Ij4NCjwvaGVhZD4NCjxib2R5Pg0KMS1hcHByb3ZlZCA8YnI DQo8YnI DQo8YnI DQpTZW50IGZyb20gUHJvdG9uIE1haWwgbW9iaWxlPGJyPg0KPGJyPg0KPGJyPg0KPGJyPg0KLS0tLS0tLS0gT3JpZ2luYWwgTWVzc2FnZSAtLS0tLS0tLTxicj4NCk9uIEF1ZyAzLCAyMDIyLCAxMToyOCBBTSwgQXJ0aXNhbnMgUHJvb2YgJmx0OyBBcnRpc2Fuc0FYVGVzdEBhcnRpc2Fuc2luYy5jb20mZ3Q7IHdyb3RlOg0KPGJsb2NrcXVvdGUgY2xhc3M9InByb3Rvbm1haWxfcXVvdGUiPjxicj4NCjEtdGVzdA0KPGRpdj48L2Rpdj4NCjwvYmxvY2txdW90ZT4NCjwvYm9keT4NCjwvaHRtbD4NCg==

    is a HTML string encoded with Base64. After decoding, you'll get this message:

    
    
    
    
    
    1-approved 


    Sent from Proton Mail mobile



    -------- Original Message --------
    On Aug 3, 2022, 11:28 AM, Artisans Proof < ArtisansAXTest@artisansinc.com> wrote:

    1-test

    To do the decoding, you can use BinData class, or .NET Interop (System.Convert::FromBase64String()).

  • LBP Profile Picture
    180 on at

    Thanks for the clarification.

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

News and Announcements

Season of Giving Solutions is Here!

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 679 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 421 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 282 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans