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?
EWS is a comprehensive service that your applications can use to access almost all the information stored in an Exchange Online, Exchange Online as part of Office 365, or Exchange on-premises mailbox.
Send a draft email message by using EWSFirst use the GetItem operation to retrieve the email message to send. Then use the SendItem operation to send the email message to recipients and save it in the Sent Items folder.
Exchange Web Services (EWS) is an application program interface (API) that allows programmers to access Microsoft Exchange items such as calendars, contacts and email.
There are two steps to sending an email with the EWS email API: Retrieve the message you want to send with the GetItem operation, specifying the ItemId for the message you want. Use the SendItem operation to send the email, specifying whether or not the message should be saved to a folder upon completion.
Whether you are using the EWS Managed API or EWS, you can send email messages in two ways. You can either send an existing message, such as a message stored in your Drafts folder, or you can create and send an email in one step.
There are two types of OAuth permissions that can be used to access EWS APIs in Exchange Online. Before you proceed with the tutorial, you will need to choose the specific permission type to use.
This is also the XML request that the EWS Managed API sends when you send a new email message. The server responds to the CreateItem request with a CreateItemResponse message that includes a ResponseCode value of NoError, which indicates that the email was created successfully, and the ItemId of the newly created message.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With