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 :
Customer experience | Sales, Customer Insights,...
Answered

Is it possible to expose Email Attachments (activitymimeattachment) on a Dynamics Portal so they can be downloaded?

(0) ShareShare
ReportReport
Posted on by 95

I have a need to expose Email Attachments (activitymimeattachment) on our customer facing portal.  I have been able to display the Subject and Body of the email, I now need to display the attachments such that the customer can download them.  Is this possible?

Thanks

Mark

I have the same question (0)
  • Verified answer
    Mark_Dowell Profile Picture
    95 on at

    As is often the case, shortly after posting my question above I worked out what I needed to do.  Firstly Entity Permissions needed to be setup to allow Read of activitymimeattachment's. I then used the following FetchXML and Liquid to retrieve and display the information I wanted:

       {% fetchxml attachment_query %}

       <fetch >

         <entity name="activitymimeattachment" >

           <attribute name="attachmentnumber" />

           <attribute name="filename" />

           <attribute name="filesize" />

           <attribute name="attachmentid" />

           <filter>

             <condition attribute="activityid" operator="eq" value="{{ emailResult['activityid'] }}" />

           </filter>

         </entity>

       </fetch>

       {% endfetchxml %}

       <div class="email">

           <ul class="attachments">

           {% for attachment in attachment_query.results.entities %}

               <li><a href="/_entity/activitymimeattachment/{{ attachment['attachmentid'].id | h }}">{{ attachment['filename'] }}</a></li>

           {% endfor %}

           </ul>

           <div class="sendon"><b>Date Sent:</b> {{ emailResult['senton'] }}</div>

           <div class="subject"><b>Subject:</b> {{ emailResult['subject'] }}</div>

           <div class="body">{{ emailResult['description'] }}</div>

       </div>

    One interesting thing to note here is that clicking on the attachment link downloads the file as you would expect which is exactly what I wanted.

    Thanks

  • Maruti Nandan Sahu Profile Picture
    5 on at

    Hey Mark, We have a similar requirement i.e: In portal, On click of email attachment, it should download. Could you please brief me a bit, where can I use this Liquid Template in our Portal Management. Thanks in Advance :)

  • Mark_Dowell Profile Picture
    95 on at

    Hi Maruti

    The code I pasted above is part of a Web Template.  These can be created via Portal Management (but I prefer to use the Portal Code Editor within XrmToolbox).  You would then create a Page Template which refers to the Web Template and finally you would create a Web Page which refers to the Page Template.  It took me a little while to understand these relationships at first, but once you have it, it makes sense.

    Don't forget to add the necessary Entity Permissions to allow Read of activitymimeattachment's.

    Thanks

    Mark

  • Davey Profile Picture
    115 on at

    Hi Mark,

    Thanks for posting the liquid for the web template.

    I can show the attachments on the portal.. However, when I click on the link it says Not Found.

    I am getting the ID and filename of the attachment. However, not sure why you have included "/_entity/activitymimeattachment" to the a href. Is this a separate webpage that you created?

    <li><a href="/_entity/activitymimeattachment/{{ attachment['attachmentid'].id | h }}">{{ attachment['filename'] }}</a></li>

  • Mark_Dowell Profile Picture
    95 on at

    Hi Davey

    /_entity/activitymimeattachment/{ID} is the url to the attachment, without "/_entity/activitymimeattachment" the browser wouldn't know what the ID relates to.

    If you are getting Not Found, ensure that you have Entity Permissions configured correctly.

  • Linn Zaw Win Profile Picture
    3,407 on at

    Mark Dowell  

    I did set the (Table) Entity Permission with the Global level (as testing) and associated with the portal user's role but I am still getting "Not Found" error. Is there any other setting that needs to be changed to allow downloading activitymimeattachment?

    This is my sample URL - portalname.microsoftcrmportals.com/.../6bd396c3-0f57-ec11-8f8f-002248154449

    2022_2D00_01_2D00_13_5F00_1_2D00_14_2D00_02.png

  • Linn Zaw Win Profile Picture
    3,407 on at

    Mark Dowell  My bad... I did not read the code properly and I was trying with 'activitymimeattachmentid'. After changing it to 'attachmentid', it works like a charm. Thanks.

  • Mark_Dowell Profile Picture
    95 on at

    Linn Zaw Win 

    All good, I'm glad you were able to work it out.

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans