gpt4 book ai didi

javascript - 如何使用 Node-ews 集成 Exchange 2010 版本的投票选项?

转载 作者:行者123 更新时间:2023-11-30 20:02:19 26 4
gpt4 key购买 nike

我无法在发送电子邮件时创建投票选项,已通过 ExtendedProperty 尽力而为,但运气不好,无法实现。我是 node js 的初学者,任何帮助/建议/指导都是可取的。

    const EWS = require('node-ews');
const NTLMAuth = require('httpntlm').ntlm;
const passwordPlainText = 'ABCDFGH';

// store the ntHashedPassword and lmHashedPassword to reuse later for reconnecting
const ntHashedPassword = NTLMAuth.create_NT_hashed_password(passwordPlainText);
const lmHashedPassword = NTLMAuth.create_LM_hashed_password(passwordPlainText);

// exchange server connection info
const ewsConfig = {
username: 'kiranraj.@demo.com',
nt_password: ntHashedPassword,
lm_password: lmHashedPassword,
host: 'https://mail.yyy.xxxx.com/'
};

// initialize node-ews
const ews = new EWS(ewsConfig);

const ewsFunction = 'CreateItem';

// define ews api function args
const ewsArgs = {
"attributes" : {
"MessageDisposition" : "SendAndSaveCopy"
},
"SavedItemFolderId": {
"DistinguishedFolderId": {
"attributes": {
"Id": "sentitems"
}
}
},
"Items" : {
"Message" : {
"ItemClass": "IPM.Note",
"Subject" : "Test EWS Email",
"Body" : {
"attributes": {
"BodyType" : "HTML"
},
"$value": "This is a test email"
},
"ExtendedProperty" : {
"ExtendedFieldURI" : {
"attributes" : {
"DistinguishedPropertySetId" : "InternetHeaders",
//"PropertySetId" : "00062008-0000-0000-C000-000000000046",
//"PropertyTag" : "0x8520",
"PropertyName" : "0x8520",
//"PropertyId" : "",
"PropertyType" : "String"
}
}
,"Value" : "Omg!appeared"
},
"ToRecipients" : {
"Mailbox" : [
//{ "EmailAddress" : "kiranraj.p@demo.com" }
{ "EmailAddress" : "lokendranath.v@demo.com" }
]
},
"IsRead": "false"
}
}
};

// define custom soap header
const ewsSoapHeader = {
't:RequestServerVersion': {
attributes: {
Version: "Exchange2010"
}
}
};

// query ews, print resulting JSON to console
ews.run(ewsFunction, ewsArgs, ewsSoapHeader)
.then(result => {
console.log(JSON.stringify(result));
console.log(JSON.stringify(ewsArgs))
})
.catch(err => {
console.log(err.stack);
});

console.log(ews)

基于上面的代码,我可以发送邮件,但是在发送的邮件中看不到投票选项。

{"ResponseMessages":{"CreateItemResponseMessage":{"attributes":{"ResponseClass":"Success"},"ResponseCode":"NoError","Items":null}}} {"attributes":{"MessageDisposition":"SendAndSaveCopy"},"SavedItemFolderId":{"DistinguishedFolderId":{"attributes":{"Id":"sentitems"}}},"Items":{"Message":{"ItemClass":"IPM.Note","Subject":"Test EWS Email","Body":{"attributes":{"BodyType":"HTML"},"$value":"<b>This is a test email</b>"},"ExtendedProperty":{"ExtendedFieldURI":{"attributes":{"DistinguishedPropertySetId":"InternetHeaders","PropertyName":"0x8520","PropertyType":"String"}},"Value":"Omg!appeared"},"ToRecipients":{"Mailbox":[{"EmailAddress":"lokendranath.v@demo.com"}]},"IsRead":"false"}}}    

这是来自 SOAPUI 的 Soap 测试请求:-

    <?xml version="1.0" encoding="utf-8"?>
<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="SendAndSaveCopy">
<m:SavedItemFolderId>
<t:DistinguishedFolderId Id="sentitems" />
</m:SavedItemFolderId>
<m:Items>
<t:Message>
<t:Subject>Saved with extendedPropertyDefinition of two days</t:Subject>
<t:Body BodyType="Text">The expiration date is contained within the extended property.</t:Body>
<t:ExtendedProperty>
<t:ExtendedFieldURI PropertySetId ="Common" PropertyName="PSETID_Common" PropertyId="0x8520" PropertyType="PT_BINARY"></t:ExtendedFieldURI>
<t:Value>Approve</t:Value>
</t:ExtendedProperty>
<t:ExtendedProperty>
<t:ExtendedFieldURI PropertySetId ="Common" PropertyName="PSETID_Common" PropertyId="0x8520" PropertyType="PT_BINARY"></t:ExtendedFieldURI>
<t:Value>Decline</t:Value>
</t:ExtendedProperty>
<t:ToRecipients>
<t:Mailbox>
<t:EmailAddress>kiranraj.p@demo.com</t:EmailAddress>
</t:Mailbox>
</t:ToRecipients>
</t:Message>
</m:Items>
</m:CreateItem>
</soap:Body>
</soap:Envelope>

返回以下响应:-

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorSchemaValidation</faultcode>
<faultstring xml:lang="en-US">The request failed schema validation: The 'PropertySetId' attribute is invalid - The value 'Common' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:GuidType' - The Pattern constraint failed.</faultstring>
<detail>
<e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorSchemaValidation</e:ResponseCode>
<e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The request failed schema validation.</e:Message>
<t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<t:LineNumber>19</t:LineNumber>
<t:LinePosition>23</t:LinePosition>
<t:Violation>The 'PropertySetId' attribute is invalid - The value 'Common' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:GuidType' - The Pattern constraint failed.</t:Violation>
</t:MessageXml>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>

最佳答案

这是设置 PidLidVerbStream 流属性的示例,请注意此属性是一个复杂的二进制流,记录在 https://msdn.microsoft.com/en-us/library/ee218541(v=exchg.80).aspx

<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="Exchange2013" />
</soap:Header>
<soap:Body>
<m:CreateItem MessageDisposition="SaveOnly">
<m:Items>
<t:Message>
<t:Subject>Test Mail</t:Subject>
<t:Body BodyType="HTML">test</t:Body>
<t:ExtendedProperty>
<t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34080" PropertyType="Binary" />
<t:Value>AgEHAAAAAAAAAAVSZXBseQhJUE0uTm90ZQdNZXNzYWdlAlJFBQAAAAAAAAAAAQAAAAAAAAACAAAAZgAAAAIAAAABAAAADFJlcGx5IHRvIEFsbAhJUE0uTm90ZQdNZXNzYWdlAlJFBQAAAAAAAAAAAQAAAAAAAAACAAAAZwAAAAMAAAACAAAAB0ZvcndhcmQISVBNLk5vdGUHTWVzc2FnZQJGVwUAAAAAAAAAAAEAAAAAAAAAAgAAAGgAAAAEAAAAAwAAAA9SZXBseSB0byBGb2xkZXIISVBNLlBvc3QEUG9zdAAFAAAAAAAAAAABAAAAAAAAAAIAAABsAAAACAAAAAQAAAADWWVzCElQTS5Ob3RlAANZZXMAAAAAAAAAAAABAAAAAgAAAAIAAAABAAAA/////wQAAAACTm8ISVBNLk5vdGUAAk5vAAAAAAAAAAAAAQAAAAIAAAACAAAAAgAAAP////8EAAAABU1heWJlCElQTS5Ob3RlAAVNYXliZQAAAAAAAAAAAAEAAAACAAAAAgAAAAMAAAD/////BAEFUgBlAHAAbAB5AAJSAEUADFIAZQBwAGwAeQAgAHQAbwAgAEEAbABsAAJSAEUAB0YAbwByAHcAYQByAGQAAkYAVwAPUgBlAHAAbAB5ACAAdABvACAARgBvAGwAZABlAHIAAANZAGUAcwADWQBlAHMAAk4AbwACTgBvAAVNAGEAeQBiAGUABU0AYQB5AGIAZQA=</t:Value>
</t:ExtendedProperty>
<t:ToRecipients>
<t:Mailbox>
<t:EmailAddress>gscales@datarumble.com</t:EmailAddress>
</t:Mailbox>
</t:ToRecipients>
</t:Message>
</m:Items>
</m:CreateItem>
</soap:Body>
</soap:Envelope>

关于javascript - 如何使用 Node-ews 集成 Exchange 2010 版本的投票选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53243887/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com