none
Show attached image office 365 outlook api RRS feed

  • Question

  • Hi, I'm using office 365 api to develop an e-mail reader...

    I can read the e-mail using the OutlookServicesClient, the problem is that the e-mail body has an image that is an attachment, and the img does not display correctly because of its src.

    See image: 


    I took a look to see how the outlook wep app handles it, and I found out that he changes the src attribute to an url.

    See image (same e-mail handled by outlook web app):

    I tried to do the same (I know that approach is not recommended, I did just for test purposes), unsuccessfully, because the url is composed  by: https://outlook.office365.com/owa/service.svc/s/GetFileAttachment?id=ATTACHMENT'S ID%3D&X-OWA-CANARY=SOMETHING THAT I DON'T KNOW WHAT IT IS

    Edit: I have full access to all attachments in the backend, including: id, contentbytes, etc.

    Any ideas about how can I show the images?

    Thank you!



    Ao infinito e além!


    • Edited by Fabio R. Luz Wednesday, January 21, 2015 5:06 PM
    Wednesday, January 21, 2015 5:04 PM

Answers

  • Hi,

    >> Any ideas about how can I show the images?

    I assume you were using Office 365 REST API.

    First, get the attachments in this message:

    https://outlook.office365.com/api/v1.0/me/messages/{message-id}/attachments

    Then look up the inline content by the ContentId (CID), in this step, you will be able to get the content bytes (base64).

    In the HTML part,

    <div>
    
    <img alt="Embedded Image" src="data:image/png;base64,{ContentBytes}" />
    
    </div>
    

    For more information, please refer to document Mail REST operations.

    Hope it will help.

    Regards,

    Jeffrey


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fabio R. Luz Thursday, January 22, 2015 12:18 PM
    Thursday, January 22, 2015 6:16 AM
    Moderator

All replies

  • Hi,

    >> Any ideas about how can I show the images?

    I assume you were using Office 365 REST API.

    First, get the attachments in this message:

    https://outlook.office365.com/api/v1.0/me/messages/{message-id}/attachments

    Then look up the inline content by the ContentId (CID), in this step, you will be able to get the content bytes (base64).

    In the HTML part,

    <div>
    
    <img alt="Embedded Image" src="data:image/png;base64,{ContentBytes}" />
    
    </div>
    

    For more information, please refer to document Mail REST operations.

    Hope it will help.

    Regards,

    Jeffrey


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fabio R. Luz Thursday, January 22, 2015 12:18 PM
    Thursday, January 22, 2015 6:16 AM
    Moderator
  • Thank you very much!

    I used the Convert.ToBase64String() to convert the content bytes. It works fine!



    Ao infinito e além!

    Thursday, January 22, 2015 12:18 PM