Как интегрировать параметры голосования для версии Exchange 2010 с помощью Node-ews? - PullRequest
0 голосов
/ 11 ноября 2018

Я не могу создать параметры голосования при отправке электронного письма, постарался изо всех сил через ExtendedProperty, но неудача не удалась. Я начинаю в узле 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"}}}    

Вот запрос Soap test от SOAPUI: -

    <?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>

1 Ответ

0 голосов
/ 13 ноября 2018

Вот пример установки свойства потока 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>
...