Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Extracting Emails content using Kingswaysoft

Posted on by 365

Hi,

I'm trying to save emails stored in dynamics to my drive. I'm able to extract the attachments by doing a WriteBinaryContent but now I would like to extract the content of the email.   to extract the attachment I'm using the "activitymimeattachment" entity.  To extract the content of the email I'm looking at the"Email" entity but it does not seem to have a body field or content field.  Am I looking at the wrong entity?

Thank you.

*This post is locked for comments

  • Pega Profile Picture
    Pega 365 on at
    RE: Extracting Emails content using Kingswaysoft

    Thank you so much Bharat, it really helped.

  • Verified answer
    BharatPremji Profile Picture
    BharatPremji 2,485 on at
    RE: Extracting Emails content using Kingswaysoft

    Hi GP (and Aric),

    If you download the Kingsway Productivity Pack:

    [View:https://www.kingswaysoft.com/products/ssis-productivity-pack:750:50]

    There is a Premium Derived Column component.  Within that there is a function called StripTagsFromHtml:

    4111.Capture2.PNG

    Using that you should see something like this:

    4111.Capture2.PNG

    Hope that helps.

    Bharat

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Extracting Emails content using Kingswaysoft

    There is no easy way to strip the Text from the HTML.

    You have two options basically:

    1. In SSIS add a Script Component that passes the HTML Text and returns the Plain Text. You can use Regular Expressions for that. See below link:

    stackoverflow.com/.../how-can-i-strip-html-tags-from-a-string-in-asp-net

    2. In you have a SQL Server, you can call a procedure or function to strip the HTML tags. See the UDF (First answer) in the link below:

    stackoverflow.com/.../best-way-to-strip-html-tags-from-a-string-in-sql-server

    Hope one of these solutions will work for you.

  • Pega Profile Picture
    Pega 365 on at
    RE: Extracting Emails content using Kingswaysoft

    Hi Bharat,

    Yes I'm now able to see the text but I also see some html code with it.  Is there some functions that can remove the HTML parts?  I'm looking at regular expression to see if that can be done but at the same time I would expect the email to be saved as an email so I might need the html code after all?!

  • BharatPremji Profile Picture
    BharatPremji 2,485 on at
    RE: Extracting Emails content using Kingswaysoft

    Hi GP

    Are you seeing <Long Text> when you put the data view in the SSIS Package?  If so, its due to the field being ntext.

    If you put in a derived column and convert the description field to (DT_WSTR,4000)[description] and put the data viewer in after that, you should see the text

    Bharat

  • Pega Profile Picture
    Pega 365 on at
    RE: Extracting Emails content using Kingswaysoft

    Thanks for your reply Bharat.  I ran the fetch and the Subject displays but not the description.  The description just say <Long Text>.  Those emails were synched from Outlook via the plugin.  Do you think that is the reason why the body is not showing up?

  • Suggested answer
    BharatPremji Profile Picture
    BharatPremji 2,485 on at
    RE: Extracting Emails content using Kingswaysoft

    Hi GP,

    The body of the email is stored in the description field. Try this fetch, it will retrieve the Subject and Body:

    <fetch top="50" >

     <entity name="email" >

       <attribute name="description" />

       <attribute name="subject" />

     </entity>

    </fetch>

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans