Skip to main content

Notifications

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

    }

}

  • LBP Profile Picture
    180 on at
    RE: cannot read message body of incoming email

    Thanks for the clarification.

  • Verified answer
    Martin Dráb Profile Picture
    232,930 Most Valuable Professional on at
    RE: cannot read message body of incoming email

    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()).

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,157 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,930 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans