## Microsoft Graph Api: #### SDK: * https://learn.microsoft.com/en-us/graph/sdks/sdk-installation#install-the-microsoft-graph-java-sdk * Java sdk: https://github.com/microsoftgraph/msgraph-sdk-java #### Permissions: * For attachment upload session: `Mail.ReadWrite` * For email send: `Mail.Send` #### Scope: * `https://graph.microsoft.com/.default` * Need to delete `IMAP` and `SMTP` scopes. #### Message format: * https://learn.microsoft.com/en-us/graph/outlook-send-mime-message * Can be sent as `Json` or `Mime`. * `Content-Type: application/json` to use JSON format in the request body. * `Content-Type: text/plain` to use MIME format in the request body. * We need to send in `Mime` format. Encode the `Mime` content in `base64` and send as request body. * For attachments set `Content-Transfer-Encoding: base64`. * **Error:** * Type: MIME content malformed, missing * Method: POST, PUT * Error code: 400 * Error message: Invalid base64 string for MIME content. ##### Attachments: * Size: upto 150 mb * Upload size in a single request 3mb. * For 3+ mb create an upload session and iteratively upload ranges of the file to attach it. * Attachment properties: > { > "contentType": "string", > "id": "string (identifier)", > "isInline": true, > "lastModifiedDateTime": "String (timestamp)", > "name": "string", > "size": 1024 > } * https://learn.microsoft.com/en-us/graph/api/resources/attachment?view=graph-rest-1.0#methods * https://learn.microsoft.com/en-us/graph/api/attachment-createuploadsession?view=graph-rest-1.0&tabs=http ##### Limits: * https://learn.microsoft.com/en-us/office365/servicedescriptions/exchange-online-service-description/exchange-online-limits#sending-limits * Emails sent per minute: 30. * Maximum recipients per email: upto 1000. #### Send email process: * Api: `https://graph.microsoft.com/v1.0/me/sendMail` * Encode entire `Mime message` object with attachments into `Base64` and set as request body. * Authorization: `Bearer $authToken` * Method: `POST`