Hi!
Im trying to create a serverside rule for a mailbox using EWS.
I want the mailbox to reply automatically to incomming emails.
To do this i have to create a template message that can be used when specifying the rule action "ServerReplyWithMessage".
I cant figure out how to create these templates..
Im using Powershell and the EWS API. I have tried to create templates by doing this:
$mail = New-Object Microsoft.Exchange.WebServices.Data.EmailMessage($service)
$mail.Subject="Test"
$mail.IsAssociated=$true
$mail.ItemClass="IPM.Note.Rules.ReplyTemplate.Microsoft"
$mail.Culture="en-US"
$mail.body="Testing"
$mail.save("Inbox")
I then get the ID of the new message $mail.id and try to create a rule using this ID:
$nrNewRule = New-Object Microsoft.Exchange.WebServices.Data.Rule
$nrNewRule.DisplayName = "Test"
$nrNewRule.Conditions.ContainsSubjectStrings.Add("test");
$nrNewRule.Actions.ServerReplyWithMessage="messageid"
$RuleOperation = New-Object Microsoft.Exchange.WebServices.Data.createRuleOperation[] 1
$RuleOperation[0] = $nrNewRule
$service.UpdateInboxRules($RuleOperation,$irInboxRules.OutlookRuleBlobExists)
The problem is that i keep getting this error "Exception calling "UpdateInboxRules" with "2" argument(s): "Exception of type 'Microsoft.Exchange.WebServices.Data.UpdateInboxRulesException' was thrown."
And im guessing its because im not creating the template in a correct way...