ballerinax/microsoft.outlook.mail Ballerina library

2.1.0

Overview

Ballerina connector for Microsoft Outlook mail provides access to the Microsoft Outlook mail service in Microsoft Graph v1.0 via the Ballerina language. It provides the capability to perform more useful functionalities provided in Microsoft outlook mail such as sending messages, listing messages, creating drafts, mail folders, deleting messages, updating messages, etc.

This module supports Microsoft Graph (Mail) API v1.0.

Prerequisites

Before using this connector in your Ballerina application, complete the following:

  1. Follow this link and obtain the client ID, client secret, and refresh token.

Quickstart

To use the Outlook mail connector in your Ballerina application, update the .bal file as follows:

Step 1 - Import connector

Import the ballerinax/microsoft.outlook.mail module into the Ballerina project.

Copy
import ballerinax/microsoft.outlook.mail;

Step 2: - Create a new connector instance

You can now make the connection configuration using the OAuth2 refresh token grant config.

Copy
mail:ConnectionConfig configuration = {
    auth: {
        refreshUrl: <REFRESH_URL>,
        refreshToken : <REFRESH_TOKEN>,
        clientId : <CLIENT_ID>,
        clientSecret : <CLIENT_SECRET>
    }
};

mail:Client outlookClient = check new(configuration);

Step 3: Invoke connector operation

  1. Send a new message using the sendMessage remote operation
Copy
public function main() returns error? {
    mail:MessageContent messageContent = {
        message: {
            subject: "Ballerina Test Email",
            importance: "Low",
            body: {
                "contentType": "HTML",
                "content": "This is sent by sendMessage operation <b>Test</b>!"
            },
            toRecipients: [
                {
                    emailAddress: {
                        address: "<email address>",
                        name: "<name>"
                    }
                }
            ]
        },
        saveToSentItems: true
    };
    http:Response response = check oneDriveClient->sendMessage(messageContent);
}
  1. Use bal run command to compile and run the Ballerina program.

You can find more samples here

Import

import ballerinax/microsoft.outlook.mail;Copy

Metadata

Released date: over 2 years ago

Version: 2.1.0

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: slbeta6

GraalVM compatible: Yes


Pull count

Total: 1646

Current verison: 4


Weekly downloads


Source repository


Keywords

Communication/Email

Cost/Paid

Vendor/Microsoft


Contributors

Other versions

See more...