none
Outlook Mail REST Api: How to get inline attachments only? RRS feed

  • Question

  • Can't seem to figure out how to get only the inline attachments from an email. The docs say that the IsInline property is filterable, but when I send this request, I get both inline and non-inline files:

        public static function getInlineAttachments($access_token, $user_email, $message_id) {

        $attachmentsFilter = array(
            "\$select" => "Id,Name,ContentType,Size,IsInline,Microsoft.OutlookServices.FileAttachment/ContentId",
            "\$filter" => "IsInline eq true"
        );

        $url = "https://outlook.office.com/api/v2.0/Me/Messages/" . $message_id . '/attachments?' . http_build_query($attachmentsFilter);

        return self::makeApiCall($access_token, $user_email, "GET", $url);
    }
    There is an alternative, to only get meta-data about the attachments and then query the API to only get the inline ones by Id, but if you get a lot of inline attachments then the GET request max length is exceeded and therefore the request fails. There is another option to batch attachments in several consecutive requests, but this is also not ideal.

    So, anybody having a good solution to this problem?

    UPDATE: I can't seem to filter by attachment Id or Name as well. It seems that even the workarounds that I thought I could use will not work. I must be missing something...
    Thursday, August 25, 2016 11:43 AM

Answers

  • Hi,

    Can you try again using the beta version of the API? You have to replace  /v1.0 with /beta.


    Regards, Sjoukje

    Please remember to click 'Mark as Answer' on the post that helps you.

    Friday, January 27, 2017 1:20 PM
    Moderator

All replies

  • Apparently the filter doesn't work with attachments.

    I was tried with graph explorer v1.0 (https://graph.microsoft.io/en-us/graph-explorer) and doesn't work :(

    https://graph.microsoft.com/v1.0/me/messages/AAMkAGI2NGVhZTVlLTI1OGMtNDI4My1iZmE5LTA5OGJiZGEzMTc0YQBGAAAAAADUuTJK1K9aTpCdqXop_4NaBwCd9nJ-tVysQos2hTfspaWRAAAAAAEMAACd9nJ-tVysQos2hTfspaWRAAD8ep2qAAA=/attachments?filter=isInline eq true

    Wednesday, January 25, 2017 3:13 PM
  • Hi,

    Can you try again using the beta version of the API? You have to replace  /v1.0 with /beta.


    Regards, Sjoukje

    Please remember to click 'Mark as Answer' on the post that helps you.

    Friday, January 27, 2017 1:20 PM
    Moderator
  • Hi,

    I'm currently trying to do the same as described in this issue, whit no success. I tried with:

    https://outlook.office.com/api/v2.0/me/mailfolders/inbox/messages/<message id>/attachments?$select=Name,IsInline&$filter=IsInline eq true

    and also 

    https://graph.microsoft.com/v1.0/me/messages/<message id>/attachments?filter=isInline eq true

    The sandbox returns all attachments, not only the inlines. Am I doing something wrong or the documentation is not accurate?


    Thursday, November 15, 2018 3:38 PM