Closed kiranraj5225 closed 5 years ago
Hello,
I was able to resolve this,
`const EWS = require('node-ews');
// exchange server connection info const ewsConfig = { username: 'username', password: 'password',
const ewsCreateFunction = 'CreateItem';
const ewsSoapHeader = { 't:RequestServerVersion': { attributes: { Version: "Exchange2010" } } };
const ewsWriteArgs = { "attributes" : { "MessageDisposition" : "SendAndSaveCopy" }, "SavedItemFolderId": { "DistinguishedFolderId": { "attributes": { "Id": "sentitems" } } }, "Items" : { "Message" : { "ItemClass": "IPM.Note", "Subject" : "Test EWS Email", "Body" : { "attributes": { "BodyType" : "Text" }, "$value": "This is a test email" }, "ExtendedProperty":{ "ExtendedFieldURI":{ "attributes":{ "DistinguishedPropertySetId":"Common", "PropertyId": "34080", "PropertyType":"Binary" } }, "Value": { "$value": 'AgEGAAAAAAAAAAVSZXBseQhJUE0uTm90ZQdNZXNzYWdlAlJFBQAAAAAAAAAAAAAAAAAAAAACAAAAZgAAAAIAAAABAAAADFJlcGx5IHRvIEFsbAhJUE0uTm90ZQdNZXNzYWdlAlJFBQAAAAAAAAAAAAAAAAAAAAACAAAAZwAAAAMAAAACAAAAB0ZvcndhcmQISVBNLk5vdGUHTWVzc2FnZQJGVwUAAAAAAAAAAAAAAAAAAAAAAgAAAGgAAAAEAAAAAwAAAA9SZXBseSB0byBGb2xkZXIISVBNLlBvc3QEUG9zdAAFAAAAAAAAAAABAAAAAAAAAAIAAABsAAAACAAAAAQAAAAHQXBwcm92ZQhJUE0uTm90ZQAHQXBwcm92ZQAAAAAAAAAAAAEAAAACAAAAAgAAAAEAAAD/////BAAAAAdEZWNsaW5lCElQTS5Ob3RlAAdEZWNsaW5lAAAAAAAAAAAAAQAAAAIAAAACAAAAAgAAAP////8EAQVSAGUAcABsAHkAAlIARQAMUgBlAHAAbAB5ACAAdABvACAAQQBsAGwAAlIARQAHRgBvAHIAdwBhAHIAZAACRgBXAA9SAGUAcABsAHkAIAB0AG8AIABGAG8AbABkAGUAcgAAB0EAcABwAHIAbwB2AGUAB0EAcABwAHIAbwB2AGUAB0QAZQBjAGwAaQBuAGUAB0QAZQBjAGwAaQBuAGUA' }
},
"ToRecipients" : {
"Mailbox" : {
"EmailAddress" : "kiranraj.p@demo.com"
}
},
"IsRead": "false"
}
} };
ews.run(ewsCreateFunction , ewsWriteArgs, ewsSoapHeader) .then(result => { console.log(JSON.stringify(result)); }) .catch(err => { console.log(err); }); ` I did received a mail with Voting buttons as response to above program.
Closing Myself
I am unable to create vote options while sending an email, tried my best through ExtendedProperty but bad luck not able to achieve. I am starter in node js, any help/suggestion/guidance is apprecitable.
`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)`
Based on above code, i am able to send the mail but the Vote Option is not visible in the sent mail.
{"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"}}}
Thanks in Advance !!!