nmarus / node-ews

A simple JSON wrapper for the Exchange Web Services (EWS) SOAP API.
MIT License
116 stars 52 forks source link

Multiple BccRecipients in ReplyToItem gives error #112

Closed bnilesh closed 4 years ago

bnilesh commented 5 years ago

I am trying to reply to an existing email using ReplyToItem with ReferenceItemId. Everything works well if I provide single BccRecipients mailbox. As soon as, I surround the Mailbox with array notation, I get the schema validation error. a:ErrorSchemaValidation: The request failed schema validation: 'ns1' is an undeclared prefix.

So far I have tried everything with regard to namespace. Added 'ts:' to types as well but no luck. Can anyone please help? I can see that 'ns1' getting added to Mailbox node when array type is provided.

var ewsCreateItemArgs = { "attributes": { "MessageDisposition": "SendAndSaveCopy" }, "SavedItemFolderId": { "DistinguishedFolderId": { "attributes": { "Id": "sentitems" } } }, "Items": { "ReplyToItem": { //following commented piece works - single email // "t:BccRecipients": { // "t:Mailbox": { // "t:EmailAddress" : debugEmail // } // }, //fails with error "t:BccRecipients": { "t:Mailbox": [ { "t:EmailAddress" : debugEmail1}, { "t:EmailAddress" : debugEmail2} ] },
"ReferenceItemId": { "attributes": { "Id": eItemId.attributes.Id, "ChangeKey": eItemId.attributes.ChangeKey } }, "NewBodyContent": { "attributes": { "BodyType": "Text" }, "$value": ${emlJob.eSubj || 'Thank you for request.'} }, } } };

//resulting xml for createitemargs `<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:wsi="http://ws-i.org/schemas/conformanceClaim/">

aaaa@aaaaa.com aaaa@aaaa.com Thank you for request. ` Thanks
siva201010sivakumar commented 5 years ago

hi bnilesh, even i am facing this issue prefix issue but if i remove the error code in bcc .i am getting the same error. Do you know how to give a reply to an email?

bnilesh commented 5 years ago

Hi Siva, for now I replaced 'ns1:t:Mailbox' with 't:Mailbox' in soap client inside node modules before sending reply. This seems to work fine but its just a band aid on the issue.

siva201010sivakumar commented 5 years ago

Hi nilesh, can you tell me the file you replaced and where?? I verified soap module under node modules but i'm unable to find out

bnilesh commented 5 years ago

Hi Siva, check it under node_modules. \node_modules\soap\lib\client.js Line#275 for me

// I have added it after following if block if(options && options.postProcess){ xml = options.postProcess(xml); } console.log("PRE-XML:",xml); xml = xml.replace(/ns1:t:Mailbox/g, 't:Mailbox'); console.log("POST-XML:",xml);

With above code, you should be able to see before and after xml created for soap request.

Good luck!

siva201010sivakumar commented 5 years ago

Awesome work, thanks for the solution nilesh. Its working for me.

siva201010sivakumar commented 5 years ago

Nilesh, can we add an attachement while seding reply??

siva201010sivakumar commented 5 years ago

NO problem Nilesh, i got that.