繁体   English   中英

EWS API更新ItemAttachment

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM