[英]EWS API updating an ItemAttachment
我正在嘗試刪除PF結構中某些項目的TNEF損壞。 我在附件上遇到了TNEF的問題。
我可以找到該項目,將其加載,刪除屬性,但無法保存附件。
我得到一個例外:
用“ 1”作為參數調用“更新”:“附件不支持此操作。”
$MSGID = $_
$psPropset = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.ItemSchema]::Attachments)
$msMessage = [Microsoft.Exchange.WebServices.Data.EmailMessage]::Bind($exchService,$MSGID,$psPropset)
$msMessage.load()
"This message has attachments :" + $msMessage.hasattachments
" "|out-default
foreach($attach in $msMessage.Attachments){
"Loading attachments :"
$attach.Load()
if ($attach.item.itemclass -eq "IPM.note")
{"Found Attached email Message : Checking for TNEF Corruption on attached Message "
$tnefProp1 = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x1204, [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::ShortArray)
$tnefProp2 = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x1205, [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::ShortArray)
$attach.Load($tnefProp1,$tnefProp2);
$propValue1 = $null
$propValue2 = $null
$foundProperty1 = $attach.item.TryGetProperty($tnefProp1, [ref]$propValue1)
$foundProperty2 = $attach.item.TryGetProperty($tnefProp2, [ref]$propValue2)
if ($foundProperty1 -or $foundProperty2)
{
"TNEF props found on item: " + $attach.item.Subject.ToString()
if ($Fix)
{
" Removing TNEF properties..."
if ($foundProperty1)
{
$attach.item.RemoveExtendedProperty($tnefProp1) | Out-Null
}
if ($foundProperty2)
{
$attach.item.RemoveExtendedProperty($tnefProp2) | Out-Null
}
$attach.item.Update([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AlwaysOverwrite)
" Finished removing TNEF properties from this item."
}
}
}
else {"Attachment was not an email"}
}
$msMessage.update([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AlwaysOverwrite)
}
}
您無法就地編輯附件。 您需要下載附件,將其從項目中刪除,編輯下載的副本,然后將其添加為新附件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.