Search code examples
office365exchangewebservices

Approve email message via exchange EWS API


I have a situation where I would need to re-route messages to a different mailbox who would be the moderator. Programmatically - is there a way to approve the message I get in the moderator's mailbox? I dont see explicit support in EWS for it. Does any other API type that microsoft has support this?


Solution

  • This is not an official approved way but the following workaround worked for me to approve and reject messages in the moderator's mailbox!

    Below is a Powershell code that does the job!

    Things to Note:

    Item Classes: $EmailMessage.ItemClass = "IPM.Note.Microsoft.Approval.Reply.Approve" $EmailMessage.ItemClass = "IPM.Note.Microsoft.Approval.Reply.Reject"
    

    Subject - Use the Normalized subject from the approval Request email and then append Accept or Reject.

    RecipientTo - Needs to be set to the Microsoft Exchange Approval Assistant Address.

    For Example, to Reject a mail from the Moderator's Mailbox:

    $PR_REPORT_TAG = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x0031,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Binary);
    $VerbResponse = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::Common,0x8524,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::String);  
    
    $ReportID = $null
    [Void]$Item.TryGetProperty($PR_REPORT_TAG,[ref]$ReportID)
    $EmailMessage.SetExtendedProperty($VerbResponse,"Reject")
    $EmailMessage.SetExtendedProperty($PR_REPORT_TAG,$ReportID)
    

    Do take a look at this link! It's nicely explained!