Hi All,
trying to use extended mapi properties. i've been asked to sort out a way of returning all items in an inbox that are not replied to or forwarded after 48 hours, by category. i'm working my way through Glen Scales' examples on his great blog, here:
http://gsexdev.blogspot.co.uk/2012/02/ews-managed-api-and-powershell-how-to.html
th mapi property i want to use is PR_LAST_VERB_EXECUTED
https://msdn.microsoft.com/en-us/library/office/cc841968.aspx
but i am struggling, somewhat. this is the (working) code i've got to retrieve an extended mapi property for a mail item in the inbox:
$inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid) $psPropset = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) $PidTagSubject = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x0037,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::string); $psPropSet.Add($PidTagSubject) #Define ItemView to retrive just 10 Items $ivItemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(10) $fiItems = $service.FindItems($Inbox.Id,$ivItemView) [Void]$service.LoadPropertiesForItems($fiItems,$psPropset) foreach($Item in $fiItems.Items){ "RecivedDate : " + $Item.DateTimeReceived"Subject : " + $Item.Subject"category : " + $Item.categories $msMessage = [Microsoft.Exchange.WebServices.Data.EmailMessage]::Bind($service,$Item.Id,$psPropSet) $SubjectVal = $null if($msmessage.TryGetProperty($PidTagSubject,[ref]$SubjectVal)){ "Extended Property : " + $SubjectVal } }
works perfectly; it outputs exactly what you'd expect:
RecivedDate : 01/15/2017 19:25:45Subject : red item 2
category : Red category
Extended Property : red item 2
well yeah, it would; it's just Glen's code.
when i edit it to retrieve the property i want, i get a fail. i change the line that defines $PidTagSubject to:
$PidTagSubject = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x1081,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Long);
and i get:
RecivedDate : 01/15/2017 19:25:45Subject : red item 2
category : Red category
Exception calling "Bind" with "3" argument(s): "The extended property attribute combination is invalid."
At C:\Users\administrator.EX2K13LONE\Documents\scratchewsold.ps1:50 char:2
+ $msMessage = [Microsoft.Exchange.WebServices.Data.EmailMessage]::Bind($service, ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ServiceResponseException
now using mfcmapi i can see that the property is as follows:
so i would expect the returned extended mapi property to be "102"...
what am i doing wrong?