Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 347
Keshi Avatar asked Apr 12 '17 02:04

Keshi


People also ask

Does EWS work with Office 365?

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.

How do I send an email with EWS?

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.

What is Exchange EWS used for?

Exchange Web Services (EWS) is an application program interface (API) that allows programmers to access Microsoft Exchange items such as calendars, contacts and email.

How do I send an email using the EWS email API?

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.

How do I send an email using the managed API?

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.

What permissions do I need to access EWS APIs in exchange online?

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.

What is a createitem response in EWS managed API?

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.


1 Answers

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!

like image 105
Shubham Avatar answered Sep 21 '22 21:09

Shubham