EWS 错误:使用 XML EWS API 创建带有附件的项目时,“设置操作对属性无效”

问题描述 投票:0回答:1

我需要创建一个带有附件的项目。

我正在使用 This 文档,以下是我的 xml 请求:

"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
 " xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\" "
 " xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" "
 " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
 "<soap:Header>"
 "<t:RequestServerVersion Version=\"Exchange2010\" />"
 "</soap:Header>"
 "<soap:Body>"
 "<m:CreateItem MessageDisposition=\"SaveOnly\">"
 "<m:Items>"
 "<t:Message>"
 "<t:Subject>%@</t:Subject>"
 "<t:Body BodyType=\"HTML\">%@</t:Body>"
 "<t:ToRecipients>"
 "%@"
 "</t:ToRecipients>"
 "<t:CcRecipients>"
 "%@"
 "</t:CcRecipients>"
 "<t:BccRecipients>"
 "%@"
 "</t:BccRecipients>"

 "<t:Attachments>"
     "<t:FileAttachment>"
     "<t:Name>FileAttachment.txt</t:Name>"
     "<t:IsInline>false</t:IsInline>"
     "<t:IsContactPhoto>false</t:IsContactPhoto>"
     "<t:Content>VGhpcyBpcyBhIGZpbGUgYXR0YWNobWVudC4=</t:Content>"
     "</t:FileAttachment>"
 "</t:Attachments>"

 "</t:Message>"
 "</m:Items>"
 "</m:CreateItem>"
 "</soap:Body>"
 "</soap:Envelope>"

但是 EWS API 返回以下错误:

    <?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:ServerVersionInfo MajorVersion="15" MinorVersion="1" MajorBuildNumber="817" MinorBuildNumber="11" Version="V2016_10_10" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
    </s:Header>
    <s:Body>
        <m:CreateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
            <m:ResponseMessages>
                <m:CreateItemResponseMessage ResponseClass="Error">
                    <m:MessageText>Set action is invalid for property.</m:MessageText>
                    <m:ResponseCode>ErrorInvalidPropertySet</m:ResponseCode>
                    <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
                    <m:MessageXml>
                        <t:FieldURI FieldURI="item:Attachments" />
                    </m:MessageXml>
                    <m:Items />
                </m:CreateItemResponseMessage>
            </m:ResponseMessages>
        </m:CreateItemResponse>
    </s:Body>
</s:Envelope>

我做错了什么吗?当我从 XML 请求中删除附件部分时,它可以工作,但不能与附件一起工作。

xml exchangewebservices email-attachments createitem
1个回答
0
投票

请检查此链接https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-send-email-messages-by-using-ews-in- Exchange,您可以轻松发送草稿消息,而无需像请求中那样设置所有内容。

© www.soinside.com 2019 - 2024. All rights reserved.