none
Graph API: approve moderation request RRS feed

  • Question

  • I want to approve moderation requests automatically by Graph API. As far as I see this feature is not supported directly but it is still possible to do it by sending a special email back to the "Microsoft Exchange Approval Assistant" as described here:

    ht tps: // gsexdev.blogspot.com/2012/07/ews-managed-api-and-powershell-how-to.html

    POST https://graph.microsoft.com/v1.0/users/<moderator_mailbox>/messages

    { "itemClass": "IPM.Note.Microsoft.Approval.Reply.Reject", "subject": "Reject:test moderator", "toRecipients": [{ "emailAddress": { "name": "Microsoft Exchange Approval Assistant", "address": "SPO_Arbitration_8ee0f36b-b76e-4942-bfa9-d7094b8f8c28@TrustifiCorp.onmicrosoft.com" } }], "singleValueExtendedProperties": [ { "id": "Binary 0x31", "value": "7g8cxkEuxk2DP2Xk+M/fxw==" }, { "id":"String {00020328-0000-0000-C000-000000000046} Id 0x8524", "value":"Rejection reason" } ] }


    The problem is that the Graph API doesn't have such property "itemClass" and without it this email doesn't do anything.

    Sunday, July 7, 2019 3:50 PM

All replies

  • You need to set the extended property for the MessageClass https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagmessageclass-canonical-property eg

    {
       "id":"String 0x001A", 
       "Value":"IPM.Note.Microsoft.Voicemail.UM.CA"
     } 

    Cheers
    Glen

    Monday, July 8, 2019 7:13 AM
  • Glen hi,

    Thank a lot for response! 

    I tried 2 variants, GraphAPI and EWS. All emails are sent successfully but nothing is changed. The moderation request email remains as is.

    POST /v1.0/users/[mailbox]/messages HTTP/1.1

    Host: graph.microsoft.com

    Content-Type: application/json

    Authorization: Bearer [TOKEN]

    {

        "subject": "Approve:test moderation 4",

           "toRecipients": [{

           "emailAddress": {

                "name": "Organization Partition_CompliancePolicyCacheOneDriveRetention",

                "address": "CompliancePolicyCacheOneDriveRetention @ TrustifiCorp.onmicrosoft.com"

            }

        }],

           "singleValueExtendedProperties": [

          {

             "id": "Binary 0x31",

             "value": "sWSzEJf+E0es4Mj8HEPfiQ=="

          },

          {

          "id":"String 0x001A",

           "value":"IPM.Note.Microsoft.Approval.Reply.Approve"

          }

        ]

    }

    Office.context.mailbox.getUserIdentityTokenAsync(asyncResult => {
       
    let request = `<soap:Envelope>
                            <
    soap:Header>
                                <
    t:RequestServerVersion Version="Exchange2016"></t:RequestServerVersion>
                            </
    soap:Header>
                            <
    soap:Body>
                                <
    m:CreateItem MessageDisposition="SendAndSaveCopy">
                                    <
    m:SavedItemFolderId>
                                        <
    t:DistinguishedFolderId Id="sentitems"></t:DistinguishedFolderId>
                                    </
    m:SavedItemFolderId>
                                    <
    m:Items>
                                        <
    t:Message>
                                            <
    t:ItemClass>IPM.Note.Microsoft.Approval.Reply.Approve</t:ItemClass>
                                            <
    t:Subject>Approve:test moderation 4</t:Subject>                                              
                                            <
    t:ExtendedProperty>
                                                <
    t:ExtendedFieldURI PropertyTag="49" PropertyType="Binary"></t:ExtendedFieldURI>
                                                <
    t:Value>sWSzEJf+E0es4Mj8HEPfiQ==</t:Value>
                                            </
    t:ExtendedProperty>
                                            <
    t:ToRecipients>
                                                <
    t:Mailbox>
                                                    <
    t:Name>Organization Partition_CompliancePolicyCacheOneDriveRetention</t:Name>
                                                    <
    t:EmailAddress>CompliancePolicyCacheOneDriveRetention @ TrustifiCorp.onmicrosoft.com</t:EmailAddress>
                                                </
    t:Mailbox>
                                            </
    t:ToRecipients>
                                        </
    t:Message>
                                    </
    m:Items>
                                </
    m:CreateItem>
                            </
    soap:Body>
                        </
    soap:Envelope>`;

        Office.
    context.mailbox.makeEwsRequestAsync(request, asyncResult => {
           
    var result = asyncResult.value;
        });
    });

    Tuesday, July 23, 2019 8:46 AM
  • You need to actually send the Message in question at the moment (in theory that's okay if your creating a draft and then your going to send the draft) your just creating the Item so you need to use the Send Operation in EWS or SendMail in the graph

    Cheers
    Glen


    Wednesday, July 24, 2019 12:17 AM
  • That's what I'm doing on both Graph API and AWS requests.
    I'm creating and sending new mail.

    POST request to the messages endpoint actually sends a new email. SendMail is just an action from some SDK that executes a POST request.
    Wednesday, July 31, 2019 4:53 PM