During a cross forest Exchange migration, some mail items in the target organization are missing the PidTagSentRepresentingName property (shown below). About 5% of all messages of a specific message class are missing the "From" field value. What I am trying to do is grab that property value from the source mailbox and then update the mail item in the target forest with that same value. My problem is that I can't seem to read that property or update it either. Does anyone have a way to read that thing? update it? Here is the property itself that I am trying to read and then update(code below):
<property tag = "0x0042001F" type = "PT_UNICODE">
<ExactNames>PR_SENT_REPRESENTING_NAME_W, PidTagSentRepresentingName</ExactNames>
<PartialNames>PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_NAME_A, ptagSentRepresentingName</PartialNames>
<Value><![CDATA[Dasani, James W]]></Value>
<AltValue>cb: 32 lpb: 520069006700670069006E0073002C0020004E0061006E006300790020005700</AltValue>
</property>
$searchFilter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.ItemSchema]::ItemClass, $MessageClass) $view = New-Object Microsoft.Exchange.WebServices.Data.ItemView($pageSize, $offset, [Microsoft.Exchange.WebServices.Data.OffsetBasePoint]::Beginning) $view.PropertySet = New-Object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::IdOnly, [Microsoft.Exchange.WebServices.Data.ItemSchema]::ItemClass, [Microsoft.Exchange.WebServices.Data.ItemSchema]::Subject, [Microsoft.Exchange.WebServices.Data.ItemSchema]::DateTimeCreated, [Microsoft.Exchange.WebServices.Data.EmailMessageSchema]::IsRead, [Microsoft.Exchange.WebServices.Data.ItemSchema]::ItemClass, [Microsoft.Exchange.WebServices.Data.EmailMessageSchema]::From, [Microsoft.Exchange.WebServices.Data.EmailMessageSchema]::Sender) $view.Traversal = [Microsoft.Exchange.WebServices.Data.ItemTraversal]::Shallow $results = $service.FindItems( $FolderId, $searchFilter, $view ) #$results = $service.FindItems( $FolderId, $view ) ForEach ($item in $results.Items) { ProcessItem $item } $moreItems = $results.MoreAvailable $offset += $pageSize
My apologies in advance for the programming shoddiness, I'm not a developer, but am trying to set this right.
Function ProcessItem( $item ) { Write-Host $item.itemclass write-host $item.getloadedpropertydefinitions() write-host $item.From write-Host $item.Sender write-host $item.Sender.tostring() #$item.From = "wut" $item.Sender = "Wut" $item.Update([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AlwaysOverwrite) }
I get multiple errors when I run this. I'm not 100% sure which property represents the PidTagSentRepresentingName (From or Sender), in fact I have this strong suspicion that I am missing something fairly major in how to go about this. Right now, I'm just trying to figure out how to read that value successfully (part 1), then how to update it successfully(part 2). I can use the same code to read the item class, loaded property definitions, all that sort of thing. I am making the connection successfully and am getting back data. Any help would be greatly appreciated.
James