diff --git a/docs/Google.md b/docs/Google.md index bfafa18..1890b6b 100644 --- a/docs/Google.md +++ b/docs/Google.md @@ -11,43 +11,60 @@ The `Google` class is instantiated by calling the `cs.NetKit.Google.new()` funct **Warning:** Shared objects are not supported by the 4D NetKit API. -## Table of contents - -- [cs.NetKit.Google.new()](#csnetkitgooglenew) -- [Google.Calendar.getCalendar()](#googlecalendargetcalendar) -- [Google.Calendar.getCalendars()](#googlecalendargetCalendars) -- [Google.Calendar.getEvent()](#googlecalendargetevent) -- [Google.Calendar.getEvents()](#googlecalendargetevents) -- [Google.mail.append()](#googlemailappend) -- [Google.mail.createLabel()](#googlemailcreatelabel) -- [Google.mail.delete()](#googlemaildelete) -- [Google.mail.deleteLabel()](#googlemaildeletelabel) -- [Google.mail.getLabel()](#googlemailgetlabel) -- [Google.mail.getLabelList()](#googlemailgetlabellist) -- [Google.mail.getMail()](#googlemailgetmail) -- [Google.mail.getMailIds()](#googlemailgetmailids) -- [Google.mail.getMails()](#googlemailgetmails) -- [Google.mail.send()](#googlemailsend) -- [Google.mail.untrash()](#googlemailuntrash) -- [Google.mail.update()](#googlemailupdate) -- [Google.mail.updateLabel()](#googlemailupdatelabel) -- [Google.user.get()](#googleuserget) -- [Google.user.getCurrent()](#googleusergetcurrent) -- [Google.user.list()](#googleuserlist) -- [labelInfo object](#labelinfo-object) -- [Status object (Google Class)](#status-object-google-class) +## Table of Contents +### [Initialization](#csnetkitgooglenew) + +* [cs.NetKit.Google.new()](#csnetkitgooglenew) + +### [Calendar](#calendar-1) + +* [Google.Calendar.getCalendar()](#googlecalendargetcalendar) +* [Google.Calendar.getCalendars()](#googlecalendargetcalendars) +* [Google.Calendar.getEvent()](#googlecalendargetevent) +* [Google.Calendar.getEvents()](#googlecalendargetevents) +* [Google.Calendar.createEvent()](#googlecalendarcreateevent) +* [Google.Calendar.updateEvent()](#googlecalendarupdateevent) +* [Google.Calendar.deleteEvent()](#googlecalendardeleteevent) +* [Event object](#event-object) + +### [Mail](#mail-1) + +* [Google.mail.send()](#googlemailsend) +* [Google.mail.append()](#googlemailappend) +* [Google.mail.update()](#googlemailupdate) +* [Google.mail.createLabel()](#googlemailcreatelabel) +* [Google.mail.updateLabel()](#googlemailupdatelabel) +* [Google.mail.deleteLabel()](#googlemaildeletelabel) +* [Google.mail.delete()](#googlemaildelete) +* [Google.mail.getLabel()](#googlemailgetlabel) +* [Google.mail.getLabelList()](#googlemailgetlabellist) +* [Google.mail.getMail()](#googlemailgetmail) +* [Google.mail.getMailIds()](#googlemailgetmailids) +* [Google.mail.getMails()](#googlemailgetmails) +* [Google.mail.untrash()](#googlemailuntrash) +* [labelInfo object](#labelinfo-object) + +### [User](#user-1) + +* [Google.user.get()](#googleuserget) +* [Google.user.getCurrent()](#googleusergetcurrent) +* [Google.user.list()](#googleuserlist) + +### [Status](#status-object) + +* [Status object](#status-object) ## **cs.NetKit.Google.new()** -**cs.NetKit.Google.new**( *oAuth2* : cs.NetKit.OAuth2Provider { ; *options* : Object } ) : cs.NetKit.Google +**cs.NetKit.Google.new**( *oAuth2* : cs.NetKit.OAuth2Provider { ; *param* : Object } ) : cs.NetKit.Google ### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |oAuth2|cs.NetKit.OAuth2Provider|->| Object of the OAuth2Provider class | -|options|Object|->| Additional options | +|param|Object|->| Additional options | |Result|cs.NetKit.Google|<-| Object of the Google class| ### Description @@ -56,7 +73,7 @@ The `Google` class is instantiated by calling the `cs.NetKit.Google.new()` funct In `oAuth2`, pass an [OAuth2Provider object](#oauth2provider). -In `options`, you can pass an object that specifies the following options: +In `param`, you can pass an object that specifies the following options: |Property|Type|Description| |---------|---|------| @@ -85,11 +102,13 @@ $oAuth2:=New OAuth2 provider($param) $google:=cs.NetKit.Google.new($oAuth2;New object("mailType"; "MIME")) ``` -## Google.Calendar.getCalendar() +## Calendar + +### Google.Calendar.getCalendar() **Google.Calendar.getCalendar**( { *id* : Text } ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -98,11 +117,11 @@ $google:=cs.NetKit.Google.new($oAuth2;New object("mailType"; "MIME")) > To retrieve calendar IDs call the getCalendars() function. If id is null, empty or missing, returns the primary calendar of the currently logged in user. -### Description +#### Description `Google.Calendar.getCalendar()` retrieves a specific calendar from the authenticated user's calendar list; using an `id` to identify the calendar and returns a `calendar` object containing details about the requested calendar. -### Example +#### Example ```4d @@ -133,18 +152,18 @@ $myCalendar:=$google.calendar.getCalendar($Calendars.calendars[0].id) ``` -## Google.Calendar.getCalendars() +### Google.Calendar.getCalendars() **Google.Calendar.getCalendar**( { *param* : Object } ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |param|Object|->|Set of options to filter or refine the calendar list request.| |Result|Object|<-|Object containing the calendar list with the related data.| -### Description +#### Description `Google.Calendar.getCalendars()` retrieves a list of calendars that the authenticated user can access. The passed filtering and paging options in `param` are returned in the `result` object. @@ -161,7 +180,7 @@ In *param*, you can pass the following optional properties: | showDeleted | Boolean | Whether to include deleted calendar list entries in the result. Optional. The default is False.| | showHidden | Boolean | Whether to show hidden entries. Optional. The default is False.| -### Returned object +#### Returned object The function returns a Collection of details about the user's calendar list in the following properties: @@ -184,7 +203,7 @@ The function returns a Collection of details about the user's calendar list in t | | | - `.componentSignature`: Signature of the component that returned the error. | -### Example +#### Example ```4d @@ -211,18 +230,18 @@ $google:=cs.NetKit.Google.new($oauth2) $Calendars:=$google.calendar.getCalendars() ``` -## Google.Calendar.getEvent() +### Google.Calendar.getEvent() **Google.Calendar.getEvent**( *param* : Object ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |param|Object|->|Object containing the necessary details to retrieve a specific event| |Result|Object|<-|Object containing the retrieved event| -### Description +#### Description `Google.Calendar.getEvent()` retrieves a specific event from a Google Calendar using its unique `eventId`. @@ -235,22 +254,22 @@ In *param*, you can pass the following properties: | maxAttendees | Integer | Max number of attendees to be returned for the event| | timeZone | String | Time zone used in the response (formatted as an IANA Time Zone Database name, e.g., "Europe/Zurich"). Defaults to UTC | -### Returned object +#### Returned object The function returns a Google [`event`](https://developers.google.com/calendar/api/v3/reference/events) object. -## Google.Calendar.getEvents() +### Google.Calendar.getEvents() **Google.Calendar.getEvents**( { *param* : Object } ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |param|Object|->|Object containing filters and options for retrieving calendar events| |Result|Object|<-|Object containing the retrieved events| -### Description +#### Description `Google.Calendar.getEvents()` retrieves events on the specified calendar. If *param* is not provided, it returns all events from the user's primary calendar. @@ -275,7 +294,7 @@ In *param*, you can pass the following optional properties: | timeZone | String | Time zone for the response, formatted as an IANA Time Zone Database name (e.g., "Europe/Zurich"). Defaults to UTC | | updatedMin | Text | Filters events based on last modification time (`ISO 8601 UTC`). When set, deleted events since this time are always included, regardless of `showDeleted` | -### Returned object +#### Returned object The method returns a [**status object**](#status-object-google-class) in addition to the following properties: @@ -298,7 +317,7 @@ The method returns a [**status object**](#status-object-google-class) in additio | defaultReminders[].minutes | Integer | Minutes before the event when the reminder triggers. | | events | Collection | List of events on the calendar. If some events have attachments, an "attachments" attribute is added, containing a collection of attachments. | -### Example +#### Example ```4d @@ -312,13 +331,220 @@ var $events:=$google.calendar.getEvents({calendarId: $myCalendar.id; top: 10}) ``` -## Google.mail.append() +### Google.calendar.createEvent() + +**Google.calendar.createEvent**(*event*: Object{; *param*: Object}) : Object + +#### Parameters + +| Parameter | Type | | Description| +| -------- | ------ | --- |--------------------------- | +|event | Object | ->|Object containing details of the calendar [event](#event-object) to create | +|param | Object | -> | Object containing additional creation options | +|Result|Object|<-|[Status object](#status-object-google-class)| + +#### Description + +`Google.calendar.createEvent()` creates a new calendar event. + +In *event*, pass an [event](#event-object) object to create. Only `start` and `end` properties are required. + +In *param*, you can pass the following additional optional properties: + +|Property|Type|Description| +|---------|--- |------| +|sendUpdates|String|Defines who should receive email notifications about the event. Acceptable values:
• `"all"` – Notify all attendees.
• `"externalOnly"` – Notify only non-Google users.
• `"none"` – No notifications sent.| +|supportsAttachments|Boolean| `true` to allow creation or modification of the [`attachments`](#attachment-object-google) property. Defaults to `false` | + +#### Returned Object + +The method returns a [**status object**](status-object-google-class) with an additional "event" property: + +|Property|Type|Description| +|---------|--- |------| +|event|Object|[Event object](#event-object) returned by the server| +|success|Boolean| [see Status object](#status-object-google-class)| +|statusText|Text| [see Status object](#status-object-google-class)| +|errors|Collection| [see Status object](#status-object-google-class)| + +#### Example + +Create an event in the Google calendar: + +```4d +var $Google:=cs.NetKit.Google.new($Oauth) +var $event; $result : Object + +$event:={} +$event.summary:="Team Meeting" +$event.start:={date: Current date; time: Current time} +$event.end:={date: Current date; time: Current time+3600} +$event.attendees:=[{email: "first.lastname@gmail.com"}] +$event.description:="description of the event" + +$result:=$Google.calendar.createEvent($event) +If (Not($result.success)) + ALERT($result.statusText) +End if +``` + +### Google.calendar.updateEvent() + +**Google.calendar.updateEvent**(*event*: Object{; *param*: Object}) : Object + +#### Parameters + +| Parameter | Type | | Description| +| -------- | ----- | -------- | --------------- | +|event |Object|->| Object containing details of the calendar [event](#event-object) to update. | +|param |Object|->| Object containing additional update options. | +|Result | Object | <-| [Status object](#status-object-google-class) | + +#### Description + +`Google.calendar.updateEvent()` updates an existing event. + +In *event*, pass an [event](#event-object) object to create. `start`, `end` and `id` properties are required. + +And in *param*, you can pass the following additional optional properties: + +| Property | Type | Description | +|------------|---------|-------------| +| sendUpdates | String | Defines who should receive email notifications about the update. Acceptable values:
• `"all"` – Notify all attendees.
• `"externalOnly"` – Notify only non-Google users.
• `"none"` – No notifications sent. | +| supportsAttachments | Boolean | `true` to allow creation or modification of the [`attachments`](#attachment-object-google) property. Defaults to `false`. | +| fullUpdate | Boolean | If `true`, the full event is replaced. If `false` (default), only specified fields are updated. | + +#### Returned Object + +The method returns a [**status object**](status-object-google-class) with an additional "event" property: + +|Property|Type|Description| +|---------|--- |------| +|event|Object|Updated [event object](#event-object) returned by the server| +|success|Boolean| [see Status object](#status-object-google-class)| +|statusText|Text| [see Status object](#status-object-google-class)| +|errors|Collection| [see Status object](#status-object-google-class)| + +#### Example + +Update an already existing event: + +```4d +#DECLARE($eventId:Text) +var $Google:=cs.NetKit.Google.new($Oauth) +var $result : Object + +$event.id:=$eventId +$event.summary:="Updated Event Title" +$event.description:="Updated Event description" +$event.start:={date: Current date; time: Current time} +$event.end:={date: Current date; time: Current time+3600} + +$result:=$Google.calendar.updateEvent($event) +If (Not($result.success)) + ALERT($result.statusText) +End if +``` + + +### Google.calendar.deleteEvent() + +**Google.calendar.deleteEvent**(*param*: Object) : Object + +#### Parameters + +| Parameter | Type | | Description | +| -------- | ----- | --- | -------------------- | +| param | Object | -> | Object containing details of the calendar [event](#event-object) to delete | +|Result|Object|<-|[Status object](#status-object-google-class)| + +#### Description + +`Google.calendar.deleteEvent()` deletes an event from a specified calendar. + +In *param*, you can pass the following properties: + +|Property|Type|Description| +|---------|--- |------| +| eventId | String | **Required.** ID of the event to delete| +| calendarId | String |**Optional.** Calendar ID. If not provided or null, uses the user's primary calendar. To retrieve calendar IDs, call `Google.calendar.getCalendars()`| +| sendUpdates | String |**Optional.** Controls which attendees of the event receive notifications about the deletion. Acceptable values:
• `"all"` – Notify all attendees of the event (Google or non-Google users)
• `"externalOnly"` – Notify only non-Google users
• `"none"` – No notifications sent| + +#### Returned Object + +The method returns a standard [**status object**](#status-object-google-class). + +#### Example + +Delete a calendar event: + +```4d +var $Google:=cs.NetKit.Google.new($Oauth) + +$status:=$google.calendar.deleteEvent({eventId: $event.id}) +If ($result.success) + ALERT("Calendar event correctly deleted") +Else + ALERT($result.statusText) +End if +``` + +### Event object + +The `event` object used with Google Calendar methods includes the following main properties. For the full list, refer to the [official Google Calendar API documentation](https://developers.google.com/calendar/api/v3/reference/events#resource). + +| Property | | Type | Description| +| ------ |---| -------- | ------------------- | +|id || Text | ID for the event.| +| calendarId | | Text | Calendar ID. If not provided, the user's primary calendar is used. Use `Google.calendar.getCalendars()` to retrieve IDs.| +| attachments | | Collection | File [attachments](#attachment-object-google) (max 25). To use this, `supportsAttachments` must be set to `true` in the request.| +| attendees| | Collection | List of attendees. | +| | email | String | Required. Email address of the attendee. | +| | displayName | String | Name of the attendee. | +| | comment| String | The attendee’s response comment. | +| | optional| Boolean | (Default: false) Whether the attendee is optional.| +| | resource| Boolean | (Default: false) Set to `true` when the attendee is a resource (e.g., room or equipment). Can only be set when the attendee is first added. Ignored in later updates. | +| | additionalGuests| Integer | (Default: `0`) Allowed number of additional guests of the attendee. | +| description | | Text | Description of the event (HTML allowed).| +| start | | Object | Start time. Use `dateTime` with optional `timeZone`, or `date` for all-day events.| +| | date | Date, Text | Start date of the event. If provided as text, use the format `"yyyy-mm-dd"`. | +| | time | Time |Start time of the event (not present if all-day event)| +| | dateTime | Text | Combined start date and time in RFC3339 format. A time zone offset is required unless `timeZone` is specified. IOverrides `date` and `time`.(not used for all-day events). | +| | timeZone | String | Time zone for the `dateTime`, using IANA format (e.g., `"Europe/Zurich"`). Defaults to UTC if not provided. | +| end | | Object | End time. Use `dateTime` with optional `timeZone`, or `date` for all-day events.| +| | date | Date, Text | End date of the event. If provided as text, use the format `"yyyy-mm-dd"`. | +| | time | Time |End time of the event (not present if all-day event)| +| | dateTime | Text |Combined date and time in RFC3339 format. A time zone offset is required unless `timeZone` is specified. Overrides `date` and `time`.(not used for all-day events). | +| | timeZone | String | Time zone for the `dateTime`, using IANA format (e.g., `"Europe/Zurich"`). Defaults to UTC if not provided. | +| eventType | | Text | Specific type of the event (Cannot be changed after creation).
Possible values: `"default"`, `"birthday"`, `"focusTime"`, `"outOfOffice"`, etc.| +| extendedProperties.private | | Object | [Custom key-value pairs](https://developers.google.com/calendar/api/v3/reference/events#extendedProperties) only visible to the event owner to store additional information (e.g; `"internalNote": "Discuss Q3 targets"`)| +| extendedProperties.shared | | Object | [Custom key-value pairs](https://developers.google.com/calendar/api/v3/reference/events#extendedProperties) shared with all attendees to share additional notes or tags (e.g., `"projectCode": "XYZ123"`).| +| focusTimeProperties| | Object | [Focus Time event-specific settings](https://developers.google.com/calendar/api/v3/reference/events#focustimeproperties). Used when `eventType` is `"focusTime"`.| +| guestsCanInviteOthers | | Boolean | (Default: true) If attendees can invite guests. | +| guestsCanModify | | Boolean | (Default: false) If attendees can edit the event. | +| guestsCanSeeOtherGuests| | Boolean | (Default: true) If attendees can see each other.| +| location | | Text | Event location.| +| recurrence\[] | | Collection | List of rules for repeating events using [RFC5545](https://www.rfc-editor.org/rfc/rfc5545) format (RRULE/EXRULE/RDATE/EXDATE (e.g., FREQ=WEEKLY;BYDAY=MO)). Does not include start/end times, use the `start` and `end` for that. Omit this field for one-time events. | +| reminders.overrides\[] | | Collection | Custom reminders.| +| | method | String | **Required**. Method of the reminder: "email" or "popup"| +| | minutes | Integer | **Required**. Time before event (in minutes) when reminder should trigger. Between 0 and 40320.| +| reminders.useDefault | | Boolean | Whether to use the calendar’s default reminders for the event.| +| source.title | | Text | Title of the source linked to the event, such as a web page or email subject.| +| source.url | | Text | URL of the source linked to the event (must use `http` or `https`).| +| status | | Text |Describes the event's current state.
Possible values: `"confirmed"` (default) `"tentative"`, or `"cancelled"`.| +| summary | | Text | Title of the event.| +| transparency | | Text | Whether the event blocks time on the calendar. Values: `"opaque"` (busy) or `"transparent"` (available).| +| visibility | | Text | Visibility level: `"default"`, `"public"`, `"private"`, or `"confidential"`.| + +## Mail + +### Google.mail.append() **Google.mail.append**( *mail* : Text { ; *labelIds* : Collection } ) : Object
**Google.mail.append**( *mail* : Blob { ; *labelIds* : Collection } ) : Object
**Google.mail.append**( *mail* : Object { ; *labelIds* : Collection } ) : Object
-### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -327,13 +553,13 @@ var $events:=$google.calendar.getEvents({calendarId: $myCalendar.id; top: 10}) |Result|Object|<-|[Status object](#status-object-google-class)| -### Description +#### Description `Google.mail.append()` appends *mail* to the user's mailbox as a DRAFT or with designated *labelIds*. >If the *labelIds* parameter is passed and the mail has a "from" or "sender" header, the Gmail server automatically adds the SENT label. -### Returned object +#### Returned object The method returns a [**status object**](status-object-google-class) with an additional "id" property: @@ -344,7 +570,7 @@ The method returns a [**status object**](status-object-google-class) with an add |statusText|Text| [see Status object](#status-object-google-class)| |errors|Collection| [see Status object](#status-object-google-class)| -### Example +#### Example To append an email : @@ -358,22 +584,22 @@ By default, the mail is created with a DRAFT label. To change the designated lab $status:=$google.mail.append($mail;["INBOX"]) ``` -## Google.mail.createLabel() +### Google.mail.createLabel() **Google.mail.createLabel**( *labelInfo* : Object ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |[labelInfo](#labelinfo-object)|Object|->|Label information.| |Result|Object|<-|[Status object](#status-object-google-class)| -### Description +#### Description `Google.mail.createLabel()` creates a new label. -### Returned object +#### Returned object The method returns a [**status object**](status-object-google-class) with an additional "label" property: @@ -384,7 +610,7 @@ The method returns a [**status object**](status-object-google-class) with an add |statusText|Text| [see Status object](#status-object-google-class)| |errors|Collection| [see Status object](#status-object-google-class)| -### Example +#### Example To create a label named 'Backup': @@ -393,11 +619,11 @@ $status:=$google.mail.createLabel({name: "Backup"}) $labelId:=$status.label.id ``` -## Google.mail.delete() +### Google.mail.delete() **Google.mail.delete**( *mailID* : Text { ; *permanently* : Boolean } ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -406,15 +632,15 @@ $labelId:=$status.label.id |Result|Object|<-|[Status object](#status-object-google-class)| -### Description +#### Description `Google.mail.delete()` deletes the specified message from the user's mailbox. -### Returned object +#### Returned object The method returns a standard [**status object**](#status-object-google-class). -### Permissions +#### Permissions This method requires one of the following OAuth scopes: @@ -423,7 +649,7 @@ https://mail.google.com/ https://www.googleapis.com/auth/gmail.modify ``` -### Example +#### Example To delete an email permanently: @@ -431,28 +657,28 @@ To delete an email permanently: $status:=$google.mail.delete($mailId; True) ``` -## Google.mail.deleteLabel() +### Google.mail.deleteLabel() **Google.mail.deleteLabel**( *labelId* : Text ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |labelId|Text|->|The ID of the label| |Result|Object|<-|[Status object](#status-object-google-class)| -### Description +#### Description `Google.mail.deleteLabel()` immediately and permanently deletes the specified label and removes it from any messages and threads that it is applied to. > This method is only available for labels with type="user". -### Returned object +#### Returned object The method returns a standard [**status object**](#status-object-google-class). -### Example +#### Example To delete a label: @@ -461,22 +687,22 @@ $status:=$google.mail.deleteLabel($labelId) ``` -## Google.mail.getLabel() +### Google.mail.getLabel() **Google.mail.getLabel**( *labelId* : Text ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |labelId|Text|->|The ID of the label| |Result|Object|<-|[labelInfo](#labelinfo-object)| -### Description +#### Description `Google.mail.getLabel()` returns the information of a label as a [labelInfo](#labelinfo-object) object. -### Returned object +#### Returned object The returned [**labelInfo**](#labelinfo-object) object contains the following additional properties: @@ -488,7 +714,7 @@ The returned [**labelInfo**](#labelinfo-object) object contains the following ad |threadsTotal|Integer|The total number of threads with the label.| |threadsUnread|Integer|The number of unread threads with the label.| -### Example +#### Example To retrieve the label name, total message count, and unread messages: @@ -499,22 +725,22 @@ $emailNumber:=$info.messagesTotal $unread:=$info.messagesUnread ``` -## Google.mail.getLabelList() +### Google.mail.getLabelList() **Google.mail.getLabelList**() : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |Result|Object|<-| Status object | -### Description +#### Description `Google.mail.getLabelList()` returns an object containing the collection of all labels in the user's mailbox. -### Returned object +#### Returned object The method returns a [**status object**](status-object-google-class) with an additional "labels" property: @@ -526,7 +752,7 @@ The method returns a [**status object**](status-object-google-class) with an add |errors|Collection| [see Status object](#status-object-google-class)| -### mailLabel object +#### mailLabel object A `mailLabel` object contains the following properties (note that additional information can be returned by the server): @@ -539,24 +765,24 @@ A `mailLabel` object contains the following properties (note that additional inf |type|Text| Owner type for the label:
- "user": User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread.
- "system": System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads.| -## Google.mail.getMail() +### Google.mail.getMail() -**Google.mail.getMail**( *mailID* : Text { ; *options* : Object } ) : Object
**Google.mail.getMail**( *mailID* : Text { ; *options* : Object } ) : Blob
+**Google.mail.getMail**( *mailID* : Text { ; *param* : Object } ) : Object
**Google.mail.getMail**( *mailID* : Text { ; *param* : Object } ) : Blob
-### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |mailID|Text|->|ID of the message to retrieve | -|options|Object|->|Options | +|param|Object|->|Options for the message to retrieve| |Result|Object | Blob|<-| Downloaded mail| -### Description +#### Description `Google.mail.getMail()` gets the specified message from the user's mailbox. -In *options*, you can pass several properties: +In *param*, you can pass several properties: |Property|Type|Description| |---------|--- |------| @@ -566,7 +792,7 @@ In *options*, you can pass several properties: -### Returned object +#### Returned object The method returns a mail in one of the following formats, depending on the `mailType`: @@ -577,22 +803,22 @@ The method returns a mail in one of the following formats, depending on the `mai -## Google.mail.getMailIds() +### Google.mail.getMailIds() -**Google.mail.getMailIds**( { *options* : Object } ) : Object +**Google.mail.getMailIds**( { *param* : Object } ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| -|options|Object|->|Options for messages to get | +|param|Object|->|Options for messages to get | |Result|Object|<-| Status object | -### Description +#### Description `Google.mail.getMailIds()` returns an object containing a collection of message ids in the user's mailbox. -In *options*, you can pass several properties: +In *param*, you can pass several properties: |Property|Type|Description| |---------|--- |------| @@ -603,7 +829,7 @@ In *options*, you can pass several properties: -### Returned object +#### Returned object The method returns a [**status object**](status-object-google-class) with additional properties: @@ -619,7 +845,7 @@ The method returns a [**status object**](status-object-google-class) with additi |errors|Collection| [see Status object](#status-object-google-class)| -### Permissions +#### Permissions This method requires one of the following OAuth scopes: @@ -629,26 +855,26 @@ https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.metadata ``` -## Google.mail.getMails() +### Google.mail.getMails() -**Google.mail.getMails**( *mailIDs* : Collection { ; *options* : Object } ) : Collection +**Google.mail.getMails**( *mailIDs* : Collection { ; *param* : Object } ) : Collection -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |mailIDs|Collection|->|Collection of strings (mail IDs), or a collection of objects (each object contains an ID property)| -|options|Object|->|Options| +|param|Object|->|Options| |Result|Collection|<-|Collection of mails in format depending on *mailType*: JMAP (collection of objects) or MIME (collection of blobs)
If no mail is returned, the collection is empty| -### Description +#### Description `Google.mail.getMails()` gets a collection of emails based on the specified *mailIDs* collection. > The maximum number of IDs supported is 100. In order to get more than 100 mails, it's necessary to call the function multiple times; otherwise, the `Google.mail.getMails()` function returns null and throws an error. -In *options*, you can pass several properties: +In *param*, you can pass several properties: |Property|Type|Description| |---------|--- |------| @@ -658,7 +884,7 @@ In *options*, you can pass several properties: -### Returned value +#### Returned value The method returns a collection of mails in one of the following formats, depending on the `mailType`: @@ -669,18 +895,18 @@ The method returns a collection of mails in one of the following formats, depend -## Google.mail.send() +### Google.mail.send() **Google.mail.send**( *email* : Text ) : Object
**Google.mail.send**( *email* : Object ) : Object
**Google.mail.send**( *email* : Blob ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |email|Text | Blob | Object|->| Email to be sent| |Result|Object|<-| [Status object](#status-object-google-class) | -### Description +#### Description `Google.mail.send()` sends an email using the MIME or JMAP formats. @@ -698,15 +924,15 @@ $status:=$Google.mail.send($email) > To avoid authentication errors, make sure your application has appropriate authorizations to send emails. One of the following OAuth scopes is required: [modify](https://www.googleapis.com/auth/gmail.modify), [compose](https://www.googleapis.com/auth/gmail.compose), or [send](https://www.googleapis.com/auth/gmail.send). For more information, see the [Authorization guide](https://developers.google.com/workspace/guides/configure-oauth-consent). -### Returned object +#### Returned object The method returns a standard [**status object**](#status-object-google-class). -## Google.mail.untrash() +### Google.mail.untrash() **Google.mail.untrash**( *mailID* : Text ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -714,15 +940,15 @@ The method returns a standard [**status object**](#status-object-google-class). |Result|Object|<-|[Status object](#status-object-google-class)| -### Description +#### Description `Google.mail.untrash()` removes the specified message from the trash. -### Returned object +#### Returned object The method returns a standard [**status object**](#status-object-google-class). -### Permissions +#### Permissions This method requires one of the following OAuth scopes: @@ -731,27 +957,27 @@ https://mail.google.com/ https://www.googleapis.com/auth/gmail.modify ``` -## Google.mail.update() +### Google.mail.update() -**Google.mail.update**( *mailIDs* : Collection ; *options* : Object) : Object +**Google.mail.update**( *mailIDs* : Collection ; *param* : Object) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |mailIDs|Collection|->|Collection of strings (mail IDs), or collection of objects (each object contains an ID property)| -|options|Object|->|Options| +|param|Object|->|Options| |Result|Object|<-| [Status object](#status-object-google-class) | > There is a limit of 1000 IDs per request. -### Description +#### Description `Google.mail.update()` adds or removes labels on the specified messages to help categorizing emails. The label can be a system label (e.g., NBOX, SPAM, TRASH, UNREAD, STARRED, IMPORTANT) or a custom label. Multiple labels could be applied simultaneously. For more information check out the [label management documentation](https://developers.google.com/gmail/api/guides/labels). -In *options*, you can pass the following two properties: +In *param*, you can pass the following two properties: |Property|Type|Description| |---------|--- |------| @@ -759,12 +985,12 @@ In *options*, you can pass the following two properties: |removeLabelIds|Collection|A collection of label IDs to remove from messages.| -### Returned object +#### Returned object The method returns a standard [**status object**](#status-object-google-class). -### Example +#### Example To mark a collection of emails as "unread": @@ -772,11 +998,11 @@ To mark a collection of emails as "unread": $result:=$google.mail.update($mailIds; {addLabelIds: ["UNREAD"]}) ``` -## Google.mail.updateLabel() +### Google.mail.updateLabel() **Google.mail.updateLabel**( *labelId* : Text ; *labelInfo* : Object ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -784,12 +1010,12 @@ $result:=$google.mail.update($mailIds; {addLabelIds: ["UNREAD"]}) |[labelInfo](#labelinfo-object)|Object|->|Label information to update| |Result|Object|<-|[Status object](#status-object-google-class)| -### Description +#### Description `Google.mail.updateLabel()` updates the specified label. > This method is only available for labels with type="user". -### Returned object +#### Returned object The method returns a [**status object**](status-object-google-class) with an additional "label" property: @@ -800,7 +1026,7 @@ The method returns a [**status object**](status-object-google-class) with an add |statusText|Text| [see Status object](#status-object-google-class)| |errors|Collection| [see Status object](#status-object-google-class)| -### Example +#### Example To update a previously created label to 'Backup January': @@ -809,13 +1035,110 @@ $status:=$google.mail.updateLabel($labelId; {name:"Backup January"}) ``` +### "Google" mail object properties + +When you send an email with the "Google" mail type, you must pass an object to `Google.mail.send()`. For a comprehensive list of properties supported by Gmail message objects, refer to the [Gmail API documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages). The most common properties are listed below: + +| Property | Type | Description | +|----------|------|-------------| +| attachments | attachment collection | The attachments for the email. | +| bccRecipients | recipient collection | The Bcc: recipients for the message. | +| ccRecipients | recipient collection | The Cc: recipients for the message. | +| from | recipient object | The sender's email address. Must match the authenticated Gmail user. | +| id | Text | Unique identifier for the message. | +| important | Boolean | If true, marks the message as important (Gmail only). | +| labelIds | Collection | List of label IDs to apply to the message. | +| replyTo | recipient collection | Email addresses to use when replying. | +| sender | recipient object | The account that generates the message. Same as `from` in most cases. | +| subject | Text | The subject line of the message. | +| toRecipients | recipient collection | The To: recipients for the message. | +| threadId | Text | The ID of the thread to which the message belongs. | + -## Google.user.get() +#### Attachment object (Google) + +| Property | Type | Description | +|----------|------|-------------| +| filename | Text | The name of the attached file. | +| mailType | Text | Indicates the Mail type to use to send and receive email's attechement. | +| content | Text | The base64-encoded content of the file. | +| size | Number | The size of the file in bytes. | +| isInline | Boolean | Set to true if the attachment is inline (e.g., embedded image). | +| contentId | Text | Content ID for referencing the attachment inline via CID. | + + +#### recipient object + +| Property | Type | Description | +|----------|------|-------------| +| emailAddress | Object | Contains the address and display name. | +| emailAddress.address | Text | The email address of the recipient. | +| emailAddress.name | Text | Display name of the recipient. | + +#### Example: Send an email with a file attachment (Google) + +```4d +var $oAuth2 : cs.NetKit.OAuth2Provider +var $token; $param; $email; $status : Object + +// Set up authentication +$param:=New object() +$param.name:="Google" +$param.permission:="signedIn" +$param.clientId:="your-client-id" // Replace with your client ID +$param.redirectURI:="http://127.0.0.1:50993/authorize/" +$param.scope:="https://www.googleapis.com/auth/gmail.send" + +$oAuth2:=New OAuth2 provider($param) +$token:=$oAuth2.getToken() + +// Create the email, specify the sender and the recipient +$email:=New object() +$email.from:=New object("emailAddress"; New object("address"; "sender@gmail.com")) +$email.toRecipients:=New collection(New object("emailAddress"; New object("address"; "recipient@gmail.com"))) +$email.subject:="Hello from NetKit" +$email.body:=New object("content"; "Hello, World!"; "contentType"; "html") + +// Create an attachment +var $attachment : Object +var $text : Text +$text:="Simple text file" +BASE64 ENCODE($text) +$attachment:=New object +$attachment.filename:="note.txt" +$attachment.mimeType:="text/plain" +$attachment.content:=$text +$email.attachments:=New collection($attachment) + +// Send the email +var $Google : Object +$Google:=New Google($token) +$status:=$Google.mail.send($email) +``` + + + +### labelInfo object + +Several Google.mail label management methods use a `labelInfo` object, containing the following properties: + +|Property|Type|Description| +|---------|--- |------| +|id|Text|The ID of the label.| +|name|Text|The display name of the label. (mandatory)| +|messageListVisibility|Text|The visibility of messages with this label in the message list.

Can be:
- "show": Show the label in the message list. <
- "hide": Do not show the label in the message list. | +|labelListVisibility|Text|The visibility of the label in the label list.

Can be:
- "labelShow": Show the label in the label list.
- "labelShowIfUnread" : Show the label if there are any unread messages with that label.
- "labelHide": Do not show the label in the label list. | +|[color](https://developers.google.com/gmail/api/reference/rest/v1/users.labels?hl=en#color)|Object|The color to assign to the label (color is only available for labels that have their type set to user).

The color object has 2 attributes :
- textColor: text: The text color of the label, represented as hex string. This field is required in order to set the color of a label.
- backgroundColor: text: The background color represented as hex string #RRGGBB (ex for black: #000000). This field is required in order to set the color of a label. | +|type|Text|The owner type for the label.

Can be:
- "system": Labels created by Gmail.
- "user": Custom labels created by the user or application.
System labels are internally created and cannot be added, modified, or deleted. They're may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads.
User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. | + +## User + +### Google.user.get() **Google.user.get**( *id* : Text {; *select* : Text } ) : Object
**Google.user.get**( *id* : Text {; *select* : Collection } ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -823,20 +1146,20 @@ $status:=$google.mail.updateLabel($labelId; {name:"Backup January"}) |select|Text \| Collection|->|Text: A comma-separated list of specific fields that you want to retrieve from each person (e.g., "names, phoneNumbers").
Collection: Collection of the specific fields.| |Result|Object|<-|Represents user's details, like names, emails, and phone numbers based on the selected fields.| -### Description +#### Description `Google.user.get()` provides information about a [user](https://developers.google.com/people/api/rest/v1/people#Person) based on the *resourceName* provided in `id` and fields optionally specified in `select`. Supported fields include *addresses*, *ageRanges*, *biographies*, *birthdays*, *calendarUrls*, *clientData*, *coverPhotos*, *emailAddresses*, *events*, *externalIds*, *genders*, *imClients*, *interests*, *locales*, *locations*, *memberships*, *metadata*, *miscKeywords*, *names*, *nicknames*, *occupations*, *organizations*, *phoneNumbers*, *photos*, *relations*, *sipAddresses*, *skills*, *urls*, *userDefined*. -### Returned object +#### Returned object The returned [user object](https://developers.google.com/people/api/rest/v1/people#Person) contains values for the specified field(s). If no fields have been specified in `select`, `Google.user.get()` returns *emailAddresses* and *names*. Otherwise, it returns only the specified field(s). -### Permissions +#### Permissions No authorization required to access public data. For private data, one of the following OAuth scopes is required: @@ -857,35 +1180,35 @@ https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/profile.language.read -## Google.user.getCurrent() +### Google.user.getCurrent() **Google.user.getCurrent**( { *select* : Text } ) : Object
**Google.user.getCurrent**( { *select* : Collection } ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |select|Text \| Collection|->|Text: A comma-separated list of specific fields that you want to retrieve from each person (e.g., "names, phoneNumbers").
Collection: Collection of the specific fields.| |Result|Object|<-|Represents user's details, like names, emails, and phone numbers based on the selected fields.| -### Description +#### Description `Google.user.getCurrent()` provides information about the authenticated [user](https://developers.google.com/people/api/rest/v1/people#Person) based on fields specified in `select`. Supported fields include *addresses*, *ageRanges*, *biographies*, *birthdays*, *calendarUrls*, *clientData*, *coverPhotos*, *emailAddresses*, *events*, *externalIds*, *genders*, *imClients*, *interests*, *locales*, *locations*, *memberships*, *metadata*, *miscKeywords*, *names*, *nicknames*, *occupations*, *organizations*, *phoneNumbers*, *photos*, *relations*, *sipAddresses*, *skills*, *urls*, *userDefined*. -### Returned object +#### Returned object The returned [user object](https://developers.google.com/people/api/rest/v1/people#Person) contains values for the specific field(s). If no fields have been specified in `select`, `Google.user.getCurrent()` returns *emailAddresses* and *names*. Otherwise, it returns only the specified field(s). -### Permissions +#### Permissions Requires the same OAuth scope package as [Google.user.get()](#permissions-15). -### Example +#### Example To retrieve information from the current user: @@ -929,24 +1252,24 @@ var $currentUser2:=$google.user.getCurrent("phoneNumbers") //returns the field "phoneNumbers" ``` -## Google.user.list() +### Google.user.list() -**Google.user.list**( { *options* : Object } ) : Object +**Google.user.list**( { *param* : Object } ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| -|options|Object|->|A set of options defining how to retrieve and filter user data| +|param|Object|->|A set of options defining how to retrieve and filter user data| |Result|Object|<-|An object containing a structured collection of [user](https://developers.google.com/people/api/rest/v1/people#Person) data organized into pages| -### Description +#### Description `Google.user.list()` provides a list of domain profiles or domain contacts in the authenticated user's domain directory. > If the contact sharing or the External Directory sharing is not allowed in the Google admin, the returned `users` collection is empty. -In *options*, you can pass the following properties: +In *param*, you can pass the following properties: |Property|Type|Description| |---------|--- |------| @@ -955,7 +1278,7 @@ In *options*, you can pass the following properties: |mergeSources|Text \| Collection|Adds related data if linked by verified join keys such as email addresses or phone numbers.
- DIRECTORY_MERGE_SOURCE_TYPE_UNSPECIFIED (Unspecified),
- DIRECTORY_MERGE_SOURCE_TYPE_CONTACT (User owned contact).| |top|Integer|Sets the maximum number of people to retrieve per page, between 1 and 1000 (default is 100).| -### Returned object +#### Returned object The returned object holds a collection of [users objects](https://developers.google.com/people/api/rest/v1/people#Person) as well as [**status object**](status-object-google-class) properties and functions that allow you to navigate between different pages of results. @@ -970,11 +1293,11 @@ The returned object holds a collection of [users objects](https://developers.goo |statusText|Text| [see Status object](#status-object-google-class)| |errors|Collection| [see Status object](#status-object-google-class)| -### Permissions +#### Permissions Requires the same OAuth scope package as [Google.user.get()](#permissions-15). -### Example +#### Example To retrieve user data in a structured collection organized into pages with a maximum of `top` users per page: @@ -1014,18 +1337,6 @@ var $userList:=$google.user.list({top:10}) ``` -## labelInfo object - -Several Google.mail label management methods use a `labelInfo` object, containing the following properties: - -|Property|Type|Description| -|---------|--- |------| -|id|Text|The ID of the label.| -|name|Text|The display name of the label. (mandatory)| -|messageListVisibility|Text|The visibility of messages with this label in the message list.

Can be:
- "show": Show the label in the message list. <
- "hide": Do not show the label in the message list. | -|labelListVisibility|Text|The visibility of the label in the label list.

Can be:
- "labelShow": Show the label in the label list.
- "labelShowIfUnread" : Show the label if there are any unread messages with that label.
- "labelHide": Do not show the label in the label list. | -|[color](https://developers.google.com/gmail/api/reference/rest/v1/users.labels?hl=en#color)|Object|The color to assign to the label (color is only available for labels that have their type set to user).

The color object has 2 attributes :
- textColor: text: The text color of the label, represented as hex string. This field is required in order to set the color of a label.
- backgroundColor: text: The background color represented as hex string #RRGGBB (ex for black: #000000). This field is required in order to set the color of a label. | -|type|Text|The owner type for the label.

Can be:
- "system": Labels created by Gmail.
- "user": Custom labels created by the user or application.
System labels are internally created and cannot be added, modified, or deleted. They're may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads.
User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. | ## Status object @@ -1047,4 +1358,4 @@ Some functions adds specific properties to the **status object**, properties are ## See also [Office365 Class](./Office365.md)
-[OAuth2Provider Class](./OAuth2Provider.md) \ No newline at end of file +[OAuth2Provider Class](./OAuth2Provider.md) diff --git a/docs/Office365.md b/docs/Office365.md index ac89671..c087d0a 100644 --- a/docs/Office365.md +++ b/docs/Office365.md @@ -15,47 +15,64 @@ The `Office365` class can be instantiated in two ways: **Warning:** Shared objects are not supported by the 4D NetKit API. -## Table of contents - -- [New Office365 provider](#new-office365-provider) -- [Office365.calendar.getCalendar()](#office365calendargetcalendar) -- [Office365.calendar.getCalendars()](#office365calendargetCalendars) -- [Office365.calendar.getEvent()](#office365calendargetevent) -- [Office365.calendar.getEvents()](#office365calendargetevents) -- [Office365.mail.append()](#office365mailappend) -- [Office365.mail.copy()](#office365mailcopy) -- [Office365.mail.createFolder()](#office365mailcreatefolder) -- [Office365.mail.delete()](#office365maildelete) -- [Office365.mail.deleteFolder()](#office365maildeletefolder) -- [Office365.mail.getFolder()](#office365mailgetfolder) -- [Office365.mail.getFolderList()](#office365mailgetfolderlist) -- [Office365.mail.getMail()](#office365mailgetmail) -- [Office365.mail.getMails()](#office365mailgetmails) -- [Office365.mail.move()](#office365mailmove) -- [Office365.mail.renameFolder()](#office365mailrenameFolder) -- [Office365.mail.reply()](#office365mailreply) -- [Office365.mail.send()](#office365mailsend) -- [Office365.mail.update()](#office365mailupdate) -- [Well-known folder names](well-known-folder-names) -- ["Microsoft" mail object properties](#microsoft-mail-object-properties) -- [Status object (Office365 Class)](#status-object) -- [Office365.user.get()](#office365userget) -- [Office365.user.getCurrent()](#office365usergetcurrent) -- [Office365.user.list()](#office365userlist) +## Table of Contents +### [Initialization](##new-office365-provider) +* [New Office365 provider](#new-office365-provider) + +### [Calendar](#calendar-1) + +* [Office365.calendar.getCalendar()](#office365calendargetcalendar) +* [Office365.calendar.getCalendars()](#office365calendargetcalendars) +* [Office365.calendar.getEvent()](#office365calendargetevent) +* [Office365.calendar.getEvents()](#office365calendargetevents) +* [Office365.calendar.createEvent()](#office365calendarcreateevent) +* [Office365.calendar.updateEvent()](#office365calendarupdateevent) +* [Office365.calendar.deleteEvent()](#office365calendardeleteevent) +* [Office365.category.list()](#office365categorylist) +* [Event object](#event-object) + +### [Mail](#mail-1) + +* [Office365.mail.send()](#office365mailsend) +* [Office365.mail.append()](#office365mailappend) +* [Office365.mail.update()](#office365mailupdate) +* [Office365.mail.reply()](#office365mailreply) +* [Office365.mail.createFolder()](#office365mailcreatefolder) +* [Office365.mail.renameFolder()](#office365mailrenamefolder) +* [Office365.mail.deleteFolder()](#office365maildeletefolder) +* [Office365.mail.getFolder()](#office365mailgetfolder) +* [Office365.mail.getFolderList()](#office365mailgetfolderlist) +* [Office365.mail.getMail()](#office365mailgetmail) +* [Office365.mail.getMails()](#office365mailgetmails) +* [Office365.mail.move()](#office365mailmove) +* [Office365.mail.copy()](#office365mailcopy) +* [Office365.mail.delete()](#office365maildelete) +* [Well-known folder names](#well-known-folder-names) +* ["Microsoft" mail object properties](#microsoft-mail-object-properties) + +### [User](#user-1) + +* [Office365.user.get()](#office365userget) +* [Office365.user.getCurrent()](#office365usergetcurrent) +* [Office365.user.list()](#office365userlist) + +### [Status](#status-object) + +* [Status object (Office365 Class)](#status-object) ## **New Office365 provider** -**New Office365 provider**( *paramObj* : Object { ; *options* : Object } ) : cs.NetKit.Office365 +**New Office365 provider**( *paramObj* : Object { ; *param* : Object } ) : cs.NetKit.Office365 ### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |paramObj|cs.NetKit.OAuth2Provider|->| Object of the OAuth2Provider class | -|options|Object|->| Additional options | +|param|Object|->| Additional options | |Result|cs.NetKit.Office365|<-| Object of the Office365 class| ### Description @@ -64,7 +81,7 @@ The `Office365` class can be instantiated in two ways: In `paramObj`, pass an [OAuth2Provider object](#new-auth2-provider). -In `options`, you can pass an object that specifies the following options: +In `param`, you can pass an object that specifies the following options: |Property|Type|Description| |---------|---|------| @@ -98,6 +115,8 @@ $office365:=New Office365 provider($oAuth2;New object("mailType"; "Microsoft")) Refer to [this tutorial](#authenticate-to-the-microsoft-graph-api-in-service-mode) for an example of connection in Service mode. +## Calendar + ### Office365.calendar.getCalendar() **Office365.calendar.getCalendar**({*id*: Text}) : Object @@ -118,7 +137,7 @@ Refer to [this tutorial](#authenticate-to-the-microsoft-graph-api-in-service-mod #### Example ```4d -var $oAuth2 : cs.NetKit.OAuth2Provider +var $oAuth2 : cs.NetKit.OAuth2Provid var $Office365 : cs.NetKit.Office365 var $params; $calendarList; $calendarA : Object @@ -294,11 +313,294 @@ var $myCaldendar:=$calendars.calendars[0] var $events:=$office365.calendar.getEvents({calendarId: $myCalendar.id; top: 10}) ``` -## Office365.mail.append() +### Office365.calendar.createEvent() + +**Office365.calendar.createEvent**(*event*: Object ) : Object + +#### Parameters + +| Parameter | Type | | Description | +| --------- | ---- |---|------------------------- | +| event | Object | -> | Object containing details of the calendar [event](#event-object) to create | +| result| Object | <- | [Status object](#status-object-microsoft-class)| + +#### Description + +`Office365.calendar.createEvent()` creates a new calendar event. + +In *event*, pass the properties you want to set for the event. + +#### Returned Object + +The function returns a [**status object**](#status-object-microsoft-class) with an additional `event` property: + +| Property | Type | Description| +| -------- | ---------- | ----------------------------------- | +| event| Object | [Event object](#event-object) returned by the server | +| success | Boolean| See [Status object](#status-object-microsoft-class) | +| statusText | Text| See [Status object](#status-object-microsoft-class) | +| errors | Collection | See [Status object](#status-object-microsoft-class) | + +#### Permissions + +One of the following permissions is required to create an event: + +| Type | Permission | +| ----------------------- | --------------------- | +| Delegated (Work/School) | `Calendars.ReadWrite` | +| Delegated (Personal) | `Calendars.ReadWrite` | +| Application | `Calendars.ReadWrite` | + +#### Example + +Create a calendar event: + +```4d +var $oAuth2 : cs.NetKit.OAuth2Provid +var $Office365 : cs.NetKit.Office365 +var $event; $result : Object + +$event:={} +$event.subject:="Team Sync" +$event.start:={date: Current date; time: Current time} +$event.end:={date: Current date; time: Current time+3600} +$event.attendees:=[{email: "first.lastname@gmail.com"}] + +$result:=$Office365.calendar.createEvent($event) +If (Not($result.success)) + ALERT($result.statusText) +End if +``` +### Office365.calendar.updateEvent() + +**Office365.calendar.updateEvent**(*event*: Object) : Object + +#### Parameters + +| Parameter | Type | | Description| +| --------- | ------ | ---- | ----------------------------- | +| event | Object | ->| Object containing the complete updated [event](#event-object). | +| Result| Object | <-| [Status object](#status-object-office365-class)| + +#### Description + +`Office365.calendar.updateEvent()` updates an existing calendar event. + +In *event*, pass the event id (mandatory) and the properties you want to update. + +To check the updatable properties, please refer to the [event object](#event-object) table below. + +> **Note**: + When using `Office365.calendar.updateEvent()`, you only need to include the fields you want to update. Any property you leave out will keep its current value, unless it needs to be recalculated due to changes in related fields (e.g., updating recurrence may affect dates). + +#### Returned Object + +The method returns a [**status object**](#status-object-office365-class) with an additional `event` property: + +| Property | Type | Description | +| ---------- | ---------- | --------------------------------------------------- | +| event | Object | Updated [event object](#event-object) returned by the server | +| success | Boolean | [see Status object](#status-object-office365-class) | +| statusText | Text | [see Status object](#status-object-office365-class) | +| errors | Collection | [see Status object](#status-object-office365-class) | + +#### Permissions + +One of the following permissions is required to update an event: + +| Type | Permission | +| ----------------------- | --------------------- | +| Delegated (Work/School) | `Calendars.ReadWrite` | +| Delegated (Personal) | `Calendars.ReadWrite` | +| Application | `Calendars.ReadWrite` | + +#### Example + +Update an already existing event calendar: + +```4d +#DECLARE($eventId:Text) +var $oAuth2 : cs.NetKit.OAuth2Provid +var $Office365 : cs.NetKit.Office365 +var $result : Object + +$event.id:=$eventId +$event.subject:="Updated Meeting Title" +$event.start:={date: Current date; time: Current time} +$event.end:={date: Current date; time: Current time+3600} + +$result:=$Office365.calendar.updateEvent($event) +If (Not($result.success)) + ALERT($result.statusText) +End if +``` + +### Office365.calendar.deleteEvent() + +**Office365.calendar.deleteEvent**(*param*: Object) : Object + +#### Parameters + +| Parameter | Type | Direction | Description | +| --------- | ------ | --------- | ------------------------------------------------------------------------------------------------------------------- | +| param | Object | -> | Object containing details for the calendar [event](#event-object) to delete| +| Result | Object | <- | [Status object](#status-object-office365-class) | + +#### Description + +`Office365.calendar.deleteEvent()` deletes a calendar event. + +In *param*, you can pass the following properties: + +| Property | Type | Description | +| ----------- | ---- | ---------------------------------------- | +| eventId | Text | **Required.** ID of the event to delete. | +| calendarId | Text | ID of the calendar. If not provided, the primary calendar of the currently logged-in user is used. | + + +#### Returned Object + +The method returns a [**status object**](#status-object-office365-class). + +#### Permissions + +One of the following permissions is required to delete an event: + +| Type | Permission | +| ----------------------- | --------------------- | +| Delegated (Work/School) | `Calendars.ReadWrite` | +| Delegated (Personal) | `Calendars.ReadWrite` | +| Application | `Calendars.ReadWrite` | + +#### Example + +Delete a calendar event: + +```4d +var $oAuth2 : cs.NetKit.OAuth2Provid +var $Office365 : cs.NetKit.Office365 + +$status:=$office365.calendar.deleteEvent({eventId: $event.event.id}) +If ($result.success) + ALERT("Calendar event correctly deleted") +Else + ALERT($result.statusText) +End if + +``` + +### Office365.category.list() + +**Office365.category.list**() : Object + +#### Parameters + +| Parameter | Type | | Description | +| --------- | ------ | -- | ------------------------------------------------------------------ | +| This method does not take any parameters.| | | | +| Result | Object | <- | [Status object](#status-object) including a `categories` property. | + +#### Description + +`Office365.category.list()` retrieves the list of defined categories used to group and organize items such as messages and calendar events in a Microsoft account. + +Each category includes a display name and a color, which can be applied when creating or updating events. + +#### Returned Object + +The method returns a [**status object**](#status-object) with an additional `categories` property: + +| Property | | Type | Description | +| --------- | --|-------- | ----------------------------- | +| success | | Boolean | [See Status object](#status-object) | +| statusText | | Text | [See Status object](#status-object) | +| errors | | Collection | [See Status object](#status-object) | +| categories | | Collection | Collection of category objects. | +| | id | Text | ID of the category. | +| | displayName | Text | A unique name that identifies the category in the user's mailbox. Once set, this name cannot be changed. | +| | color | Text | A pre-set color constant mapped to one of 25 predefined Outlook colors (e.g., `"Preset0"`, `"Preset12"`). See the list of [color constants](https://learn.microsoft.com/en-us/graph/api/resources/outlookcategory?view=graph-rest-1.0#properties) for more details. | + +#### Permissions + +One of the following permissions is required: + +| Type | Permission | +| ----------------------- | ---------------------- | +| Delegated (Work/School) | `MailboxSettings.Read` | +| Delegated (Personal) | `MailboxSettings.Read` | +| Application | `MailboxSettings.Read` | + +#### Example + +```4d +var $oAuth2 : cs.NetKit.OAuth2Provid +var $Office365 : cs.NetKit.Office365 +var $result : Object +var $toDisplay : Collection + +$result:=$o365.category.list() +$toDisplay:=[] + +If (Not($result.success)) + ALERT($result.statusText) +Else + // Process the category list + For each ($category; $result.categories) + $toDisplay.push($category.displayName) + End for each +End if +``` +### Event object + +The `event` object used with Microsoft Calendar methods includes the following main properties. For the full list, refer to the [official Microsoft documentation](https://learn.microsoft.com/en-us/graph/api/resources/event?view=graph-rest-1.0). + +| Property | | Type | Description| Updatable | +| -------- | -- | ----- | ----------------------- |-----------| +| id | | Text | ID for the event. Case-sensitive and read-only. | | +| calendarId | | Text | Calendar ID. If not provided, the user's primary calendar is used. | | +| attachments| | Collection | Event file [attachments](#attachment-object).| | +| attendees | | Collection | List of attendees.|Yes| +| | emailAddress | Text | Required. Attendee’s email address.| | +| | type | Text | Attendee role: `"required"`, `"optional"`, or `"resource"`.| | +| body | | Object |Body of the message associated with the event.| Yes | +| | content | Text | Content of the body| | +| | contentType | Text | Type of the content.
Possible values: `"text"` or `"html"`.| | +| categories | | Collection | List of categories associated with the event. Must match the `displayName` of categories returned by [`Office365.category.list()`](#office365categorylist). |Yes| +| start | | Object | Start time of the event.|Yes| +| | date | Date | Start time of the event. If provided as text, use the format `"yyyy-mm-dd"`.| | +| | time | Time| Start time (not used for all-day events).| | +| | dateTime | Text | Combined start date and time (`"yyyy-mm-ddThh:mm:ss"` format). Overrides `date` and `time`. | | +| | timeZone | Text | Time zone for the `dateTime`, using IANA format (e.g., `"Europe/Zurich"`). Defaults to UTC if not provided.| | +| end | | Object | End time of the event.|Yes| +| | date | Date | End date of the event. If provided as text, use the format `"yyyy-mm-dd"`.| | +| | time | Time | End time (not used for all-day events).| | +| | dateTime | Text | Combined end date and time (`"yyyy-mm-ddThh:mm:ss"` format). Overrides `date` and `time`.| | +| | timeZone | Text | Time zone for the `dateTime`, using IANA format (e.g., `"Europe/Zurich"`). Defaults to UTC if not provided.| | +| isAllDay | | Boolean | (Default: false) Set to `true` if it's an all-day event.|Yes| +| isDraft | | Boolean |(Default: false) Set to `true` if changes have been made to the meeting but not yet sent to attendees.| | +| isCancelled | | Boolean | (Default: false) Whether the event is canceled.| | +| isReminderOn| | Boolean | (Default: false) Whether a reminder is set for the event.| Yes | +| isOnlineMeeting | | Boolean | (Default: false) Set to `true` to create an online meeting. Once set, the event stays online and further changes to this setting are ignored.|Yes| +| onlineMeetingProvider | | Text | Provider used: `"teamsForBusiness"`, `"skypeForBusiness"`, `"skypeForConsumer"`, etc.|Yes | +|location| | Object| Event [location object](https://learn.microsoft.com/en-us/graph/api/resources/location?view=graph-rest-1.0).|Yes | +| reminderMinutesBeforeStart | | Integer | Time in minutes before start to trigger reminder.|Yes | +| responseRequested | | Boolean | Whether a response is requested from attendees. Default is `true`.|Yes | +| recurrence | | Object | [Recurrence pattern](https://learn.microsoft.com/en-us/graph/api/resources/recurrencepattern?view=graph-rest-1.0) (e.g., daily, weekly) .| Yes | +| seriesMasterId | | Text | ID of the recurring series master event, if this event is part of a recurring series. | | +| importance | | Text | Event importance: `"low"`, `"normal"`, or `"high"`.|Yes | +| sensitivity | | Text | Event sensitivity: `"normal"`, `"personal"`, `"private"`, `"confidential"`.| Yes | +| showAs| | Text | Availability status: `busy`, `free`, etc.| Yes | +| subject | | Text | Event title or subject line.| Yes | +| allowNewTimeProposals | | Boolean | (Default: true) Whether attendees can propose a new time.| | +| hideAttendees | | Boolean | (Default: false) If `true`, attendees will only see themselves.|Yes| + +## Mail + +### Office365.mail.append() **Office365.mail.append**( *email* : Object ; *folderId* : Text) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -306,18 +608,18 @@ var $events:=$office365.calendar.getEvents({calendarId: $myCalendar.id; top: 10} |folderId|Text|->| Id of the destination folder. Can be a folder id or a [Well-known folder name](#well-known-folder-name).| |Result|Object|<-| [Status object](#status-object) | -### Description +#### Description `Office365.mail.append()` creates a draft *email* in the *folderId* folder. In `email`, pass the email to create. It must be of the [Microsoft mail object](#microsoft-mail-object-properties) type. -### Returned object +#### Returned object The method returns a [status object](#status-object). -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -328,18 +630,18 @@ One of the following permissions is required to call this API. For more informat |Application|Mail.ReadWrite| -### Example +#### Example ```4d $status:=$office365.mail.append($draft; $folder.id) ``` -## Office365.mail.copy() +### Office365.mail.copy() **Office365.mail.copy**( *mailId* : Text ; *folderId* : Text) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -347,15 +649,15 @@ $status:=$office365.mail.append($draft; $folder.id) |folderId|Text|->| Id of the destination folder. Can be a folder id or a [Well-known folder name](#well-known-folder-name).| |Result|Object|<-| [Status object](#status-object) | -### Description +#### Description `Office365.mail.copy()` copies the *mailId* email to the *folderId* folder within the user's mailbox. -### Returned object +#### Returned object The method returns a [status object](#status-object). -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -365,7 +667,7 @@ One of the following permissions is required to call this API. For more informat |Delegated (personal Microsoft account)|Mail.ReadWrite| |Application|Mail.ReadWrite| -### Example +#### Example To copy an email from a folder to another: @@ -374,11 +676,11 @@ $status:=$office365.mail.copy($mailId; $folderId) ``` -## Office365.mail.createFolder() +### Office365.mail.createFolder() **Office365.mail.createFolder**( *name* : Text { ; *isHidden* : Boolean { ; *parentFolderId* : Text } }) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -393,7 +695,7 @@ By default, the new folder is not hidden. Pass `True` in the isHidden parameter By default, the new folder is created at the root folder of the mailbox. If you want to create it within an existing folder, pass its id in the *parentFolderId* parameter. -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -404,11 +706,11 @@ One of the following permissions is required to call this API. For more informat |Application|Mail.ReadWrite| -### Returned object +#### Returned object The method returns a [status object](#status-object). -### Example +#### Example You want to create a "Backup" mail folder at the root of your mailbox and move an email to this folder: @@ -422,23 +724,23 @@ If($status.success=True) End if ``` -## Office365.mail.delete() +### Office365.mail.delete() **Office365.mail.delete**( *mailId* : Text ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |mailId|Text|->| Id of the mail to delete| |Result|Object|<-| [Status object](#status-object) | -### Description +#### Description `Office365.mail.delete()` deletes the *mailId* email. -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -450,7 +752,7 @@ One of the following permissions is required to call this API. For more informat |Application|Mail.ReadWrite| -### Returned object +#### Returned object The method returns a [status object](#status-object). @@ -458,7 +760,7 @@ The method returns a [status object](#status-object). **Note:** You may not be able to delete items in the recoverable items deletions folder (for more information, see the [Microsoft's documentation website](https://learn.microsoft.com/en-us/graph/api/message-delete?view=graph-rest-1.0&tabs=http)). -### Example +#### Example You want to delete all mails in the *$mails* collection: @@ -468,22 +770,22 @@ For each($mail;$mails) End for each ``` -## Office365.mail.deleteFolder() +### Office365.mail.deleteFolder() **Office365.mail.deleteFolder**( *folderId* : Text ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |folderId|Text|->| ID of the folder to delete. Can be a folder id or a [Well-known folder name](#well-known-folder-name) if one exists.| |Result|Object|<-| [Status object](#status-object) | -### Description +#### Description `Office365.mail.deleteFolder()` deletes the *folderId* mail folder. -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -494,21 +796,21 @@ One of the following permissions is required to call this API. For more informat |Application|Mail.ReadWrite| -### Returned object +#### Returned object The method returns a [status object](#status-object). -### Example +#### Example ```4d $status:=$office365.mail.deleteFolder($folderId) ``` -## Office365.mail.getFolder() +### Office365.mail.getFolder() **Office365.mail.getFolder**( *folderId* : Text ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -517,7 +819,7 @@ $status:=$office365.mail.deleteFolder($folderId) `Office365.mail.getFolder()` allows you to get a **mailFolder** object from its *folderId*. -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -528,7 +830,7 @@ One of the following permissions is required to call this API. For more informat |Application|Mail.ReadBasic.All, Mail.Read, Mail.ReadWrite| -### mailFolder object +#### mailFolder object The method returns a **mailFolder** object containing the following properties (additional information can be returned by the server): @@ -543,20 +845,20 @@ The method returns a **mailFolder** object containing the following properties ( |unreadItemCount|Integer|Number of items in the mailFolder marked as unread.| -## Office365.mail.getFolderList() +### Office365.mail.getFolderList() -**Office365.mail.getFolderList**( *options* : Object ) : Object +**Office365.mail.getFolderList**( *param* : Object ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| -|options|Object|->| Description of folders to get| +|param|Object|->| Description of folders to get| |Result|Object|<-| Status object that contains folder list and other information| `Office365.mail.getFolderList()` allows you to get a mail folder collection of the signed-in user. -In *options*, pass an object to define the folders to get. The available properties for that object are (all properties are optional): +In *param*, pass an object to define the folders to get. The available properties for that object are (all properties are optional): | Property | Type | Description | |---|---|---| @@ -569,7 +871,7 @@ In *options*, pass an object to define the folders to get. The available propert |includeHiddenFolders|boolean|True to include hidden folders in the response. False (default) to not return hidden folders. | -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -580,7 +882,7 @@ One of the following permissions is required to call this API. For more informat |Application|Mail.ReadBasic.All, Mail.Read, Mail.ReadWrite| -### Returned object +#### Returned object The method returns a status object containing the following properties: @@ -610,7 +912,7 @@ The method returns an empty collection in the `folders` property if: - no folders are found at the defined location - an error is thrown -### Example +#### Example You want to : @@ -625,25 +927,25 @@ $subfolders:=$office365.mail.getFolderList($result.folders[8].id) ``` -## Office365.mail.getMail() +### Office365.mail.getMail() -**Office365.mail.getMail**( *mailId* : Text { ; *options* : Object } ) : Object
**Office365.mail.getMail**( *mailId* : Text { ; *options* : Object } ) : Blob +**Office365.mail.getMail**( *mailId* : Text { ; *param* : Object } ) : Object
**Office365.mail.getMail**( *mailId* : Text { ; *param* : Object } ) : Blob -### Parameters +#### Parameters |Parameter||Type||Description| |-----|----|--- |:---:|------| |mailId||Text|->| Id of the mail to get| -|options||Object|->|Format options for the returned mail object| +|param||Object|->|Format options for the returned mail object| ||mailType|Text|| Type of the mail object to return. Available values:
- "MIME"
- "JMAP"
- "Microsoft" (default)
By default if omitted, the same format as the [`mail.type` property](#new-office365-provider) is used| ||contentType|Text|| Format of the `body` and `uniqueBody` properties to be returned. Available values:
- "text"
- "html" (default)| |Result||Blob | Object|<-| Downloaded mail| `Office365.mail.getMail()` allows you to get a single mail from its *mailId*. -By default, the mail is returned with its original format, as defined in the [`mail.type` property of the provider](#new-office365-provider). However, you can convert it to any type using the `mailType` property of the *options* parameter. +By default, the mail is returned with its original format, as defined in the [`mail.type` property of the provider](#new-office365-provider). However, you can convert it to any type using the `mailType` property of the *param* parameter. -You can also select the preferred format of the `body` and `uniqueBody` properties of the returned mail using the `contentType` property of the *options* parameter. +You can also select the preferred format of the `body` and `uniqueBody` properties of the returned mail using the `contentType` property of the *param* parameter. The data type of the function result depends on the mail type: @@ -657,7 +959,7 @@ If an error occurs, the function returns Null and an error is generated. See also [Microsoft's documentation website](https://learn.microsoft.com/en-us/graph/api/message-get?view=graph-rest-1.0&tabs=http). -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -668,7 +970,7 @@ One of the following permissions is required to call this API. For more informat |Application|Mail.ReadBasic.All, Mail.Read| -### Example +#### Example Download a specific email: @@ -677,22 +979,22 @@ $mail:=$office.mail.getMail($mailId) ``` -## Office365.mail.getMails() +### Office365.mail.getMails() -**Office365.mail.getMails**( *options* : Object ) : Object +**Office365.mail.getMails**( *param* : Object ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| -|options|Object|->| Description of mails to get| +|param|Object|->| Description of mails to get| |Result|Object|<-| Status object that contains mail list and other information| `Office365.mail.getMails()` allows you to get messages in the signed-in user's mailbox (for detailed information, please refer to the [Microsoft's documentation website](https://learn.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0&tabs=http)). This method returns mail bodies in HTML format only. -In *options*, pass an object to define the mails to get. The available properties for that object are (all properties are optional): +In *param*, pass an object to define the mails to get. The available properties for that object are (all properties are optional): | Property | Type | Description | |---|---|---| @@ -704,7 +1006,7 @@ In *options*, pass an object to define the mails to get. The available propertie |orderBy|text|Defines how returned items are ordered. Default is ascending order. Syntax: "fieldname asc" or "fieldname desc" (replace "fieldname" with the name of the field to be arranged).| -### Returned object +#### Returned object The method returns a status object containing the following properties: @@ -722,7 +1024,7 @@ The method returns a status object containing the following properties: | success | | Boolean | `True` if the `Office365.mail.getFolderList()` call is successful, `False` otherwise | | mails || Collection | Collection of [Microsoft mail objects](#microsoft-mail-object-properties). If no mail is returned, the collection is empty| -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -732,7 +1034,7 @@ One of the following permissions is required to call this API. For more informat |Delegated (personal Microsoft account)|Mail.ReadBasic, Mail.Read, Mail.ReadWrite| |Application|Mail.ReadBasic.All, Mail.Read, Mail.ReadWrite| -### Example +#### Example You want to retrieve *sender* and *subject* properties of all the mails present in the Inbox folder, using its [well-known folder name](#well-known-folder-name): @@ -744,11 +1046,11 @@ $param.select:="sender,subject" $mails:=$office365.mail.getMails($param) ``` -## Office365.mail.move() +### Office365.mail.move() **Office365.mail.move**( *mailId* : Text ; *folderId* : Text) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -756,16 +1058,16 @@ $mails:=$office365.mail.getMails($param) |folderId|Text|->| Id of the destination folder. Can be a folder id or a [Well-known folder name](#well-known-folder-name).| |Result|Object|<-| [Status object](#status-object) | -### Description +#### Description `Office365.mail.move()` moves the *mailId* email to the *folderId* folder. It actually creates a new copy of the email in the destination folder and removes the original email from its source folder. -### Returned object +#### Returned object The method returns a [status object](#status-object). -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -776,7 +1078,7 @@ One of the following permissions is required to call this API. For more informat |Application|Mail.ReadWrite| -### Example +#### Example To move an email from a folder to another: @@ -784,11 +1086,11 @@ To move an email from a folder to another: $status:=$office365.mail.move($mailId; $folderId) ``` -## Office365.mail.renameFolder() +### Office365.mail.renameFolder() **Office365.mail.renameFolder**( *folderId* : Text ; *name* : Text ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -796,13 +1098,13 @@ $status:=$office365.mail.move($mailId; $folderId) |name|Text|->| New display name for the folder| |Result|Object|<-| [Status object](#status-object) | -### Description +#### Description `Office365.mail.renameFolder()` renames the *folderId* mail folder with the provided *name*. Note that the renamed folder ID is different from the *folderId*. You can get it in the returned [status object](#status-object). -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -813,11 +1115,11 @@ One of the following permissions is required to call this API. For more informat |Application|Mail.ReadWrite| -### Returned object +#### Returned object The method returns a [status object](#status-object). -### Example +#### Example You want to rename the the "Backup" folder to "Backup_old": @@ -826,11 +1128,11 @@ $status:=$office365.mail.renameFolder($folderId; "Backup_old") ``` -## Office365.mail.reply() +### Office365.mail.reply() **Office365.mail.reply**( *reply* : Object ; *mailId* : Text { ; *replyAll* : Boolean } ) : Object -### Parameters +#### Parameters |Parameter||Type||Description| |----|-----|--- |:---:|------| @@ -841,7 +1143,7 @@ $status:=$office365.mail.renameFolder($folderId; "Backup_old") |replyAll||Boolean|->| True to reply to all recipients of the message. Default=False| |Result|Object|<-| [Status object](#status-object) | -### Description +#### Description `Office365.mail.reply()` replies to the sender of *mailId* message and, optionnally, to all recipients of the message. @@ -849,11 +1151,11 @@ $status:=$office365.mail.renameFolder($folderId; "Backup_old") If you pass `False` in *replyAll* and if the original message specifies a recipient in the `replyTo` property, the reply is sent to the recipients in `replyTo` and not to the recipient in the `from` property. -### Returned object +#### Returned object The method returns a [status object](#status-object) -### Permissions +#### Permissions One of the following permissions is required to call this API. For more information, including how to choose permissions, see the [Permissions section on the Microsoft documentation](https://docs.microsoft.com/en-us/graph/permissions-reference). @@ -863,7 +1165,7 @@ One of the following permissions is required to call this API. For more informat |Delegated (personal Microsoft account)|Mail.Send| |Application|Mail.Send| -### Example +#### Example To reply to an email and create a conversation: @@ -876,18 +1178,18 @@ $status:=$office365.mail.reply($reply; $mails.mailId) -## Office365.mail.send() +### Office365.mail.send() **Office365.mail.send**( *email* : Text ) : Object
**Office365.mail.send**( *email* : Object ) : Object
**Office365.mail.send**( *email* : Blob ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| |email|Text | Blob | Object|->| Email to be sent| |Result|Object|<-| [Status object](#status-object) | -### Description +#### Description `Office365.mail.send()` sends an email using the MIME or JSON formats. @@ -909,15 +1211,15 @@ $status:=$Office365.mail.send($email) > To avoid authentication errors, make sure your application asks for permission to send emails through the Microsoft Graph API. See [Permissions](https://docs.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=http#permissions). -### Returned object +#### Returned object The method returns a [status object](#status-object). -## Office365.mail.update() +### Office365.mail.update() **Office365.mail.update**( *mailId* : Text ; *updatedFields* : Object ) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -925,7 +1227,7 @@ The method returns a [status object](#status-object). |updatedFields|Object|->|email fields to update| |Result|Object|<-| [Status object](#status-object) | -### Description +#### Description `Office365.mail.update()` allows you to update various properties of received or drafted emails. @@ -955,17 +1257,17 @@ In *updatedFields*, you can pass several properties: * Existing properties that are not included in the *updatedFields* object will maintain their previous values or be recalculated based on changes to other property values. * Specific properties, such as the body or subject, can only be updated for emails in draft status (isDraft = true). -### Returned object +#### Returned object The method returns a [status object](#status-object). -## Well-known folder names +### Well-known folder names Outlook creates certain folders for users by default. Instead of using the corresponding `folder id` value, for convenience, you can use the well-known folder name when accessing these folders. Well-known names work regardless of the locale of the user's mailbox. For example, you can get the Drafts folder using its well-known name "draft". For more information, please refer to the [Microsoft Office documentation](https://docs.microsoft.com/en-us/graph/api/resources/mailfolder?view=graph-rest-1.0). -## "Microsoft" mail object properties +### "Microsoft" mail object properties When you send an email with the "Microsoft" mail type, you must pass an object to `Office365.mail.send()`. For a comprehensive list of properties supported by Microsoft mail objects, please refer to the [Microsoft Office documentation](https://learn.microsoft.com/en-us/graph/api/resources/message?view=graph-rest-1.0#properties). Most common properties are listed below: @@ -987,7 +1289,7 @@ When you send an email with the "Microsoft" mail type, you must pass an object t | subject |Text| The subject of the message.| | toRecipients |[recipient](#recipient-object) collection | The To: recipients for the message. | -### Attachment object +#### Attachment object | Property | Type | Description | |---|---|---| @@ -1001,14 +1303,14 @@ When you send an email with the "Microsoft" mail type, you must pass an object t |size|Number|The size in bytes of the attachment.| |getContent()|Function|Returns the contents of the attachment object in a `4D.Blob` object.| -### itemBody object +#### itemBody object | Property | Type | Description | Can be null of undefined | |---|---|---|---| |content|Text|The content of the item.|No| |contentType|Text| The type of the content. Possible values are `"text"` and `"html"` |No| -### recipient object +#### recipient object | Property || Type | Description | Can be null of undefined | |---|---|---|---|---| @@ -1016,14 +1318,14 @@ When you send an email with the "Microsoft" mail type, you must pass an object t ||address|Text|The email address of the person or entity.|No| ||name|Text| The display name of the person or entity.|Yes| -### internetMessageHeader object +#### internetMessageHeader object | Property | Type | Description | Can be null of undefined | |---|---|---|---| |name | Text|Represents the key in a key-value pair.|No| |value|Text|The value in a key-value pair.|No| -### followup flag object +#### followup flag object | Property | Type | Description | |---|---|---| @@ -1031,7 +1333,7 @@ When you send an email with the "Microsoft" mail type, you must pass an object t |flagStatus|Text|The status for follow-up for an item. Possible values are `"notFlagged"`, `"complete"`, and `"flagged"`.| |startDateTime|[dateTime | TimeZone](#datetime-and-timezone)| The date and time that the follow-up is to begin.| -### dateTime and TimeZone +#### dateTime and TimeZone |Property|Type|Description| |---|---|---| @@ -1044,7 +1346,7 @@ In general, the timeZone property can be set to any of the time zones currently -### Example: Create an email with a file attachment and send it +#### Example: Create an email with a file attachment and send it Send an email with an attachment, on behalf of a Microsoft 365 user: @@ -1091,7 +1393,7 @@ $Office365:=New Office365 provider($token; New object("mailType"; "Microsoft")) $status:=$Office365.mail.send($email) ``` -### Status object +## Status object Several Office365.mail functions return a standard `**status object**`, containing the following properties: @@ -1105,20 +1407,20 @@ Several Office365.mail functions return a standard `**status object**`, containi Basically, you can test the `success` and `statusText` properties of this object to know if the function was correctly executed. -### Error handling +#### Error handling When an error occurs during the execution of an Office365.mail function: - if the function returns a [`**status object**`](#status-object), the error is handled by the status object and no error is thrown, - if the function does not return a **status object**, an error is thrown that you can intercept with a project method installed with `ON ERR CALL`. - - -## Office365.user.get() +## User + +### Office365.user.get() **Office365.user.get**( *id* : Text { ; *select* : Text }) : Object
**Office365.user.get**( *userPrincipalName* : Text { ; *select* : Text }) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| @@ -1127,7 +1429,7 @@ When an error occurs during the execution of an Office365.mail function: |select|Text|->| Set of properties to be returned| |Result|Object|<-| Object holding information on the user| -### Description +#### Description `Office365.user.get()` returns information on the user whose ID matches the *id* parameter, or whose User Principal Name (UPN) matches the *userPrincipalName* parameter. @@ -1140,7 +1442,7 @@ In *select*, you can pass a string that contains a specific set of properties yo > The list of available properties is available on [Microsoft's documentation website](https://docs.microsoft.com/en-us/graph/api/resources/user?view=graph-rest-1.0). -### Returned object +#### Returned object By default, if the *select* parameter is omitted, the command returns an object with the following properties: @@ -1162,11 +1464,11 @@ Otherwise, the object contains the properties specified in the `select` paramete For more details on user information, see [Microsoft's documentation website](https://docs.microsoft.com/en-us/graph/api/resources/user?view=graph-rest-1.0). -## Office365.user.getCurrent() +### Office365.user.getCurrent() **Office365.user.getCurrent**({*select* : Text}) : Object -### Description +#### Description `Office365.user.getCurrent()` returns information on the current user. In this case, it requires a [signed-in user](https://docs.microsoft.com/en-us/graph/auth-v2-user), and therefore a delegated permission. @@ -1176,7 +1478,7 @@ In *select*, pass a string that contains a set of properties you want to retriev By default, if the *select* parameter is not defined, the command returns an object with a default set of properties (see the [property table](#returned-object)). -### Example +#### Example To retrieve information from the current user: @@ -1202,22 +1504,22 @@ $userInfo:=$Office365.user.getCurrent("id,userPrincipalName,\ principalName,displayName,givenName,mail") ``` -## Office365.user.list() +### Office365.user.list() -**Office365.user.list**({*options*: Object}) : Object +**Office365.user.list**({*param*: Object}) : Object -### Parameters +#### Parameters |Parameter|Type||Description| |---------|--- |:---:|------| -|options|Object|->| Additional options for the search| +|param|Object|->| Additional options for the search| |result|Object|<-| Object holding a collection of users and additional info on the request| -### Description +#### Description `Office365.user.list()` returns a list of Office365 users. -In *options*, you can pass an object to specify additional search options. The following table groups the available search options: +In *param*, you can pass an object to specify additional search options. The following table groups the available search options: | Property | Type | Description | |---|---|---| @@ -1227,7 +1529,7 @@ In *options*, you can pass an object to specify additional search options. The f |top| Integer | Defines the page size for a request. Maximum value is 999. If `top` is not defined, the default value is applied (100). When a result set spans multiple pages, you can use the `.next()` function to ask for the next page. See [Microsoft's documentation on paging](https://docs.microsoft.com/en-us/graph/paging) for more information. | |orderBy| Text | Defines how the returned items are ordered. By default, they are arranged in ascending order. The syntax is "fieldname asc" or "fieldname desc". Replace "fieldname" with the name of the field to be arranged. | -### Returned object +#### Returned object The returned object holds a collection of users as well as status properties and functions that allow you to navigate between different pages of results. @@ -1245,7 +1547,7 @@ By default, each user object in the collection has the [default set of propertie | users | Collection | Collection of objects with information on users.| -### Example +#### Example ```4d var $oAuth2 : cs.NetKit.OAuth2Provider @@ -1288,4 +1590,4 @@ Until (Not($userList4.next())) ## See also [Google Class](./Google.md)
-[OAuth2Provider Class](./OAuth2Provider.md) \ No newline at end of file +[OAuth2Provider Class](./OAuth2Provider.md)