{"id":15784826,"url":"https://github.com/nmarus/node-ews","last_synced_at":"2025-04-05T14:08:32.073Z","repository":{"id":44699651,"uuid":"50711587","full_name":"nmarus/node-ews","owner":"nmarus","description":"A simple JSON wrapper for the Exchange Web Services (EWS) SOAP API.","archived":false,"fork":false,"pushed_at":"2023-10-02T21:46:54.000Z","size":195,"stargazers_count":116,"open_issues_count":43,"forks_count":54,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-28T17:49:09.629Z","etag":null,"topics":["ews","exchange","microsoft"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nmarus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-01-30T06:02:04.000Z","updated_at":"2024-10-10T08:57:27.000Z","dependencies_parsed_at":"2024-01-13T18:00:24.102Z","dependency_job_id":"7b01f489-014a-4d80-94e5-32fc79c03b6a","html_url":"https://github.com/nmarus/node-ews","commit_stats":{"total_commits":122,"total_committers":16,"mean_commits":7.625,"dds":"0.28688524590163933","last_synced_commit":"b5e2b3a897177fd2820ef1e57d6ef666dd83bfca"},"previous_names":["cumberlandgroup/node-ews"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmarus%2Fnode-ews","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmarus%2Fnode-ews/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmarus%2Fnode-ews/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmarus%2Fnode-ews/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nmarus","download_url":"https://codeload.github.com/nmarus/node-ews/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345854,"owners_count":20924102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ews","exchange","microsoft"],"created_at":"2024-10-04T20:05:36.520Z","updated_at":"2025-04-05T14:08:32.056Z","avatar_url":"https://github.com/nmarus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### NOTE: This REPO is no longer being actively maintained.\n### =====================================\n\n# node-ews\n###### A simple JSON wrapper for the Exchange Web Services (EWS) SOAP API\n\n```\nnpm install node-ews\n```\n\n#### Updates in 3.4.0 (new)\n- Use ntlm-client to enable NTLMv2\n\n#### Updates in 3.2.0 (new)\n- Reverted back to official soap library to address workaround in issue #17\n- Added Notifications from PR #50 (See example 5)\n- Code cleanup\n\n#### About\nA extension of node-soap with ntlm-client to make queries to Microsoft's Exchange\nWeb Service API work. Utilize node-soap for json to xml query processing and\nreturns responses as json objects.\n\n##### Features:\n- Supports NTLMv1, NTLMv2, Basic, or Bearer Authentication.\n- Connects to configured EWS Host and downloads it's WSDL file so it might be concluded that this is \"fairly\" version agnostic\n- After downloading the WSDL file, the wrapper dynamically exposes all EWS SOAP functions\n- Attempts to standardize Microsoft's WSDL by modifying the file to include missing service name, port, and bindings\n- This DOES NOT work with anything Microsoft Documents as using the EWS Managed API.\n- When using NTLMv2 you have to you your Windows username and not your email address\n\n#### Example 1: Get Exchange Distribution List Members Using ExpandDL\n###### https://msdn.microsoft.com/EN-US/library/office/aa564755.aspx\n```js\nconst EWS = require('node-ews');\n\n// exchange server connection info\nconst ewsConfig = {\n  username: 'myuser@domain.com',\n  password: 'mypassword',\n  host: 'https://ews.domain.com'\n};\n\n// initialize node-ews\nconst ews = new EWS(ewsConfig);\n\n// define ews api function\nconst ewsFunction = 'ExpandDL';\n\n// define ews api function args\nconst ewsArgs = {\n  'Mailbox': {\n    'EmailAddress':'publiclist@domain.com'\n  }\n};\n\n// query EWS and print resulting JSON to console\news.run(ewsFunction, ewsArgs)\n  .then(result =\u003e {\n    console.log(JSON.stringify(result));\n  })\n  .catch(err =\u003e {\n    console.log(err.message);\n  });\n```\n\n#### Example 2: Setting OOO Using SetUserOofSettings\n###### https://msdn.microsoft.com/en-us/library/office/aa580294.aspx\n```js\nconst EWS = require('node-ews');\n\n// exchange server connection info\nconst ewsConfig = {\n  username: 'myuser@domain.com',\n  password: 'mypassword',\n  host: 'https://ews.domain.com'\n};\n\n// initialize node-ews\nconst ews = new EWS(ewsConfig);\n\n// define ews api function\nconst ewsFunction = 'SetUserOofSettings';\n\n// define ews api function args\nconst ewsArgs = {\n  'Mailbox': {\n    'Address':'email@somedomain.com'\n  },\n  'UserOofSettings': {\n    'OofState':'Enabled',\n    'ExternalAudience':'All',\n    'Duration': {\n      'StartTime':'2016-08-22T00:00:00',\n      'EndTime':'2016-08-23T00:00:00'\n    },\n    'InternalReply': {\n      'Message':'I am out of office.  This is my internal reply.'\n    },\n    'ExternalReply': {\n      'Message':'I am out of office. This is my external reply.'\n    }\n  }\n};\n\n// query ews, print resulting JSON to console\news.run(ewsFunction, ewsArgs)\n  .then(result =\u003e {\n    console.log(JSON.stringify(result));\n  })\n  .catch(err =\u003e {\n    console.log(err.stack);\n  });\n```\n\n#### Example 3: Getting OOO Using GetUserOofSettings\n###### https://msdn.microsoft.com/en-us/library/office/aa563465.aspx\n```js\nconst EWS = require('node-ews');\n\n// exchange server connection info\nconst ewsConfig = {\n  username: 'myuser@domain.com',\n  password: 'mypassword',\n  host: 'https://ews.domain.com'\n};\n\n// initialize node-ews\nconst ews = new EWS(ewsConfig);\n\n// define ews api function\nconst ewsFunction = 'GetUserOofSettings';\n\n// define ews api function args\nconst ewsArgs = {\n  'Mailbox': {\n    'Address':'email@somedomain.com'\n  }\n};\n\n// query ews, print resulting JSON to console\news.run(ewsFunction, ewsArgs)\n  .then(result =\u003e {\n    console.log(JSON.stringify(result));\n  })\n  .catch(err =\u003e {\n    console.log(err.stack);\n  });\n```\n\n#### Example 4: Sending Email (version 3.0.1 required to avoid issue #17)\n##### https://msdn.microsoft.com/en-us/library/office/aa566468\n\n```js\nconst EWS = require('node-ews');\n\n// exchange server connection info\nconst ewsConfig = {\n  username: 'myuser@domain.com',\n  password: 'mypassword',\n  host: 'https://ews.domain.com'\n};\n\n// initialize node-ews\nconst ews = new EWS(ewsConfig);\n\n// define ews api function\nconst ewsFunction = 'CreateItem';\n\n// define ews api function args\nconst ewsArgs = {\n  \"attributes\" : {\n    \"MessageDisposition\" : \"SendAndSaveCopy\"\n  },\n  \"SavedItemFolderId\": {\n    \"DistinguishedFolderId\": {\n      \"attributes\": {\n        \"Id\": \"sentitems\"\n      }\n    }\n  },\n  \"Items\" : {\n    \"Message\" : {\n      \"ItemClass\": \"IPM.Note\",\n      \"Subject\" : \"Test EWS Email\",\n      \"Body\" : {\n        \"attributes\": {\n          \"BodyType\" : \"Text\"\n        },\n        \"$value\": \"This is a test email\"\n      },\n      \"ToRecipients\" : {\n        \"Mailbox\" : {\n          \"EmailAddress\" : \"someone@gmail.com\"\n        }\n      },\n      \"IsRead\": \"false\"\n    }\n  }\n};\n\n// query ews, print resulting JSON to console\news.run(ewsFunction, ewsArgs)\n  .then(result =\u003e {\n    console.log(JSON.stringify(result));\n  })\n  .catch(err =\u003e {\n    console.log(err.stack);\n  });\n```\n\n#### Example 5: Creating a Push Notification Service Listener\n\n```js\n// specify listener service options\nconst serviceOptions = {\n  port: 8080, // defaults to port 8000\n  path: '/', // defaults to '/notification'\n  // If you do not have NotificationService.wsdl it can be found via a quick Google search\n  xml:fs.readFileSync('NotificationService.wsdl', 'utf8') // the xml field is required\n};\n\n// create the listener service\news.notificationService(serviceOptions, function(response) {\n  console.log(new Date().toISOString(), '| Received EWS Push Notification');\n  console.log(new Date().toISOString(), '| Response:', JSON.stringify(response));\n  // Do something with response\n  return {SendNotificationResult: { SubscriptionStatus: 'OK' } }; // respond with 'OK' to keep subscription alive\n  // return {SendNotificationResult: { SubscriptionStatus: 'UNSUBSCRIBE' } }; // respond with 'UNSUBSCRIBE' to unsubscribe\n});\n\n// The soap.listen object is passed through the promise so you can optionally use the .log() functionality\n// https://github.com/vpulim/node-soap#server-logging\n.then(server =\u003e {\n  server.log = function(type, data) {\n    console.log(new Date().toISOString(), '| ', type, ':', data);\n  };\n});\n\n// create a push notification subscription\n// https://msdn.microsoft.com/en-us/library/office/aa566188\nconst ewsConfig = {\n  PushSubscriptionRequest: {\n    FolderIds: {\n      DistinguishedFolderId: {\n        attributes: {\n          Id: 'inbox'\n        }\n      }\n    },\n    EventTypes: {\n      EventType: ['CreatedEvent']\n    },\n    StatusFrequency: 1,\n    // subscription notifications will be sent to our listener service\n    URL: 'http://' + require('os').hostname() + ':' + serviceOptions.port + serviceOptions.path\n  }\n};\news.run('Subscribe', ewsConfig);\n```\n\n### Office 365\n\nBelow is a template that works with Office 365.\n\n```js\nconst EWS = require('node-ews');\n\n// exchange server connection info\nconst ewsConfig = {\n  username: 'myuser@domain.com',\n  password: 'mypassword',\n  host: 'https://outlook.office365.com',\n  auth: 'basic'\n};\n\n// initialize node-ews\nconst ews = new EWS(ewsConfig);\n\n// define ews api function\nconst ewsFunction = 'ExpandDL';\n\n// define ews api function args\nconst ewsArgs = {\n  'Mailbox': {\n    'EmailAddress':'publiclist@domain.com'\n  }\n};\n\n// query EWS and print resulting JSON to console\news.run(ewsFunction, ewsArgs)\n  .then(result =\u003e {\n    console.log(JSON.stringify(result));\n  })\n  .catch(err =\u003e {\n    console.log(err.message);\n  });\n```\n\n### Advanced Options\n\n#### Adding Optional Soap Headers\n\nTo add an optional soap header to the Exchange Web Services request, you can pass an optional 3rd variable to the ews.run() function as demonstrated by the following:\n\n```js\nconst EWS = require('node-ews');\n\n// exchange server connection info\nconst ewsConfig = {\n  username: 'myuser@domain.com',\n  password: 'mypassword',\n  host: 'https://ews.domain.com'\n};\n\n// initialize node-ews\nconst ews = new EWS(ewsConfig);\n\n// define ews api function\nconst ewsFunction = 'GetUserOofSettings';\n\n// define ews api function args\nconst ewsArgs = {\n  'Mailbox': {\n    'Address':'email@somedomain.com'\n  }\n};\n\n// define custom soap header\nconst ewsSoapHeader = {\n  't:RequestServerVersion': {\n    attributes: {\n      Version: \"Exchange2013\"\n    }\n  }\n};\n\n// query ews, print resulting JSON to console\news.run(ewsFunction, ewsArgs, ewsSoapHeader)\n  .then(result =\u003e {\n    console.log(JSON.stringify(result));\n  })\n  .catch(err =\u003e {\n    console.log(err.stack);\n  });\n\n```\n\n#### Enable Basic Auth instead of NTLM:\n\n```js\n// exchange server connection info\nconst ewsConfig = {\n  username: 'myuser@domain.com',\n  password: 'mypassword',\n  host: 'https://ews.domain.com',\n  auth: 'basic'\n};\n\n// initialize node-ews\nconst ews = new EWS(ewsConfig);\n```\n\n#### Enable Bearer Auth instead of NTLM:\n\n```js\n// exchange server connection info\nconst ewsConfig = {\n  username: 'myuser@domain.com',\n  token: 'oauth_token...',\n  host: 'https://ews.domain.com',\n  auth: 'bearer'\n};\n\n// initialize node-ews\nconst ews = new EWS(ewsConfig);\n```\n\n#### Disable SSL verification:\n\nTo disable SSL authentication modify the above examples with the following:\n\n**Basic and Bearer Auth**\n\n```js\nconst options = {\n rejectUnauthorized: false,\n strictSSL: false\n};\nprocess.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';\n\nconst ews = new EWS(config, options);\n```\n\n**NTLM**\n\n```js\nconst options = {\n strictSSL: false\n};\nprocess.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';\n\nconst ews = new EWS(config, options);\n```\n\n#### Specify Temp Directory:\n\nBy default, node-ews creates a temp directory to store the xsd and wsdl file retrieved from the Exchange Web Service Server.\n\nTo override this behavior and use a persistent folder add the following to your config object.\n\n```js\n// exchange server connection info\nconst ewsConfig = {\n  username: 'myuser@domain.com',\n  password: 'mypassword',\n  host: 'https://ews.domain.com',\n  temp: '/path/to/temp/folder'\n};\n\n// initialize node-ews\nconst ews = new EWS(ewsConfig);\n```\n\n# Constructing the ewsArgs JSON Object\n\nTake the example of \"[FindItem](https://msdn.microsoft.com/en-us/library/office/aa566107.aspx)\" that is referenced in the Microsoft EWS API Docs as follows:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003csoap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\n               xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\"\u003e\n  \u003csoap:Body\u003e\n    \u003cFindItem xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\"\n               xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\"\n              Traversal=\"Shallow\"\u003e\n      \u003cItemShape\u003e\n        \u003ct:BaseShape\u003eIdOnly\u003c/t:BaseShape\u003e\n      \u003c/ItemShape\u003e\n      \u003cParentFolderIds\u003e\n        \u003ct:DistinguishedFolderId Id=\"deleteditems\"/\u003e\n      \u003c/ParentFolderIds\u003e\n    \u003c/FindItem\u003e\n  \u003c/soap:Body\u003e\n\u003c/soap:Envelope\u003e\n```\n\nThe equivalent JSON Request for node-ews (ewsArgs) would be:\n\n```js\n{\n  'attributes': {\n    'Traversal': 'Shallow'\n  },\n  'ItemShape': {\n    'BaseShape': 'IdOnly'\n  },\n  'ParentFolderIds' : {\n    'DistinguishedFolderId': {\n      'attributes': {\n        'Id': 'deleteditems'\n      }\n    }\n  }\n}\n```\n\nIt is important to note the structure of the request. Items such as \"BaseShape\" are children of their parent element. In this case it is \"ItemShape\". In regards \"BaseShape\" it is enclosed between an opening and closing tag so it is defined as a direct clid of \"ItemShape\".\n\nHowever, \"DistinguishedFolderId\" has no closing tag and you must specify an ID. Rather than a direct child object, you must use the JSON child object \"attributes\".\n\n## License\n\nMIT License Copyright (c) 2016 Nicholas Marus\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmarus%2Fnode-ews","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnmarus%2Fnode-ews","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmarus%2Fnode-ews/lists"}