我创建了一个EWS请求来附加电子邮件,但是我从中收到空值,但状态为“成功”。 顺便说一句。
我首先创建了一个makeEwsRequestAsync请求,用于将电子邮件保存到草稿中,并且已经可以使用,但是当我尝试使用此请求向其添加附件时,它没有添加。任何建议或帮助请
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
function createAttachment() {
var request =
'<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
'xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
'xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
' <soap:Body>' +
' <CreateAttachment xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
' <ParentItemId Id="'+itemID+'" />' +
' <Attachments>' +
' <t:ItemAttachment>' +
' <t:Name>Please</t:Name>' +
' <t:Message>' +
' <t:ItemClass>IPM>Note</t:ItemClass>' +
' <t:Subject>test</t:Subject>' +
' <t:Body BodyType="Text">my test</t:Body>' +
' </t:Message>' +
' </t:ItemAttachment>' +
' </Attachments>' +
' </CreateAttachment>' +
' </soap:Body>' +
'</soap:Envelope>';
return request;
}
</script>
这是我创建的附件EWS请求
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
function composeMail(emailSubject, emailDescription) {
var subject= subjectPrefix + " " + emailSubject;
var request =
'<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
' 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>' +
' <RequestServerVersion Version="Exchange2007_SP1" />' +
' </soap:Header>' +
' <soap:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
' <m:CreateItem MessageDisposition="SaveOnly">' +
' <m:SavedItemFolderId>' +
' <t:DistinguishedFolderId Id="drafts" />' +
' </m:SavedItemFolderId>' +
' <m:Items>' +
' <t:Message>' +
' <t:ItemClass>IPM.Note</t:ItemClass>' +
' <t:Subject>' + subject + '</t:Subject>' +
' <t:Body BodyType="HTML">' + emailDescription + '</t:Body>' +
' <t:Importance>Low</t:Importance>' +
' <t:ToRecipients>' +
' <t:Mailbox>' +
' <t:EmailAddress>' + recepient + '</t:EmailAddress>' +
' </t:Mailbox>' +
' </t:ToRecipients>' +
' <t:IsRead>false</t:IsRead>' +
' </t:Message>' +
' </m:Items>' +
' </m:CreateItem>' +
' </soap:Body>' +
'</soap:Envelope>';
return request;
}
</script>
这是我创建的电子邮件EWS请求
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
function send() {
var request =
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
'xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
'xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
' <soap:Body>' +
' <SendItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"' +
' SaveItemToFolder="true">' +
' <ItemIds>' +
' <t:ItemId Id="' + itemID + '"/>' +
' </ItemIds>' +
' </SendItem>' +
' </soap:Body>' +
'</soap:Envelope>';
return request;
}
</script>
这是我的发送EWS请求,我使用
对其进行呼叫
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
function sendRequest(emailSubject, emailDescription, emailItemID) {
// Create a local variable that contains the mailbox.
try {
itemID = Office.context.mailbox.item.itemId;
Office.context.mailbox.makeEwsRequestAsync(
composeMail(emailSubject, emailDescription), callbackCompose);
Office.context.mailbox.makeEwsRequestAsync(
createAttachment(), callbackAttachment);
Office.context.mailbox.makeEwsRequestAsync(
send(), callbackSend);
} catch (error) {
$("#id-error-msg").text(error);
}
</script>
答案 0 :(得分:1)
在我看来,例如不良的XML
for product in response.css('ul.product-cards-grid li.product-wrapper'):
prod_href = p.css('li::attr(data-producturl)').extract()
prod_name = p.css('li::attr(data-producttitle)').extract_first()
prod_img = p.css('li::attr(data-productimg)').extract_first()
prod_id = p.css('li::attr(data-productid)').extract_first()
将在服务器上产生验证错误(您应该在服务器的EWS响应中看到,例如您的请求应该是
'<t:ItemClass>IPM>Note</t:ItemClass>' +
答案 1 :(得分:0)
如果要从撰写模式处理电子邮件,可以参考Microsoft团队的本文档。我相信它会更加简单和全面。
否则,如果要从阅读模式处理电子邮件。可以有两种选择。
一种是通过使用Rest API。但是,发出此请求需要满足一些要求。我的在台式机上不起作用,但在Web上可用,但是如果您想尝试,可以参考以下链接:https://docs.microsoft.com/en-us/outlook/add-ins/use-rest-api
遇到最低要求问题。我找到了一种使用Exchange Web服务请求(EWS)使其工作的方法。它主要使用XML文件发送请求以交换Web服务并返回响应。
但是,我发现我需要获取该电子邮件的MimeContent才能添加到我的CreateItem xml请求中。请检查此链接以获取更多信息。 https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/getitem-operation-email-message
然后,我使用MimeContent将现有项目添加到新电子邮件中。您可以使用以下链接进行检出:https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-add-attachments-by-using-ews-in-exchange