Skip to content
bladerunner2020 edited this page Jan 21, 2019 · 2 revisions

Get Exchange Distribution List Members Using ExpandDL

var ewsFunction = 'ExpandDL';

var ewsArgs = {
  'Mailbox': {
    'EmailAddress':'publiclist@domain.com'
  }
};

Setting OOO Using SetUserOofSettings

var ewsFunction = 'SetUserOofSettings';

var ewsArgs = {
  'Mailbox': {
    'Address':'email@somedomain.com'
  },
  'UserOofSettings': {
    'OofState':'Enabled',
    'ExternalAudience':'All',
    'Duration': {
      'StartTime':'2016-08-22T00:00:00',
      'EndTime':'2016-08-23T00:00:00'
    },
    'InternalReply': {
      'Message':'I am out of office.  This is my internal reply.'
    },
    'ExternalReply': {
      'Message':'I am out of office. This is my external reply.'
    }
  }
};

Getting OOO Using GetUserOofSettings

var ewsFunction = 'GetUserOofSettings';

var ewsArgs = {
  'Mailbox': {
    'Address':'email@somedomain.com'
  }
};

Sending Email

var ewsFunction = 'CreateItem';

var ewsArgs = {
  "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"
      },
      "ToRecipients" : {
        "Mailbox" : {
          "EmailAddress" : "someone@gmail.com"
        }
      },
      "IsRead": "false"
    }
  }
};

Finding Shared Meeting Room Calendar Folder

const ewsArgs = {
    'FolderShape': {
        'BaseShape': 'IdOnly'
    },
    'FolderIds':{
        'DistinguishedFolderId': {
            'attributes': {
                'Id': 'calendar'
            },
            'Mailbox': {
                "EmailAddress": { "$value" : 'meeting_room@acme.com' }   
            }
        }
    }
}

Get Calendar Events

const ewsArgs = {
    'attributes': {
        'Traversal': 'Shallow'
    },
    'ItemShape': {
        'BaseShape': 'IdOnly',
        'AdditionalProperties': {	
            'FieldURI': [
                { 'attributes': { 'FieldURI': 'folder:DisplayName' }},
                { 'attributes': { 'FieldURI': 'item:Subject' }},
                { 'attributes': { 'FieldURI': 'item:Importance' }},
                { 'attributes': { 'FieldURI': 'item:HasAttachments' }},
                { 'attributes': { 'FieldURI': 'item:DateTimeSent' }},
                { 'attributes': { 'FieldURI': 'calendar:Location' }},
                { 'attributes': { 'FieldURI': 'calendar:Organizer' }},
                { 'attributes': { 'FieldURI': 'calendar:Start' }},
                { 'attributes': { 'FieldURI': 'calendar:End' }}
            ]
        }
    },
    'CalendarView' : {
        'attributes' : {
            'MaxEntriesReturned': 10,
            'StartDate' : "2019-01-01T00:00:00.000Z",
            'EndDate': "2019-01-21T00:00:00.000Z"
        },

    },
    'ParentFolderIds' : {
        'FolderId': {
            'attributes': {
                'Id': id,                // Id that is returned by FindItem
                'ChangeKey' : changeKey  // ChangeKey that is returned by FindItem
            }
        }
    }
}