Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29767

EWS Mark mail as read after moving

$
0
0

With the help of Exchange Web Services we're trying to move a mail to a specific folder and then mark it as read. To do this we use the following code:

Write-Verbose "Move mail to '$('\PowerShell\' + $SQLTickets.ScriptName)'"
$DestinationPathID = Find-MailboxFolderIDHC @FindMailParams -Path ('\PowerShell\' + $SQLTickets.ScriptName)
$Mail.Move($DestinationPathID) | Out-Null

Write-Verbose 'Mark mails as read'
$Mail.IsRead = $true
$Mail.Update([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AutoResolve)

When I check the result of this action the mail is indeed correctly moved to the folder en has the IsRead property set to True. However, this is not visible in MS Outlook, it's still not marked as Read.

When it hits this line:

$Mail.Update([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AutoResolve)

It throws the follwing error which I can't seem to fix:

Exception calling "Update" with "1" argument(s): "The specified object was not found in the store."

Viewing all articles
Browse latest Browse all 29767

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>