Outlook
Learn how to list emails of an Outlook inbox and send emails using Unipile SDK.
Prerequisites
Before we start, you need to:
-
Create an Application in the dashboard.
-
Create an API Key from the dashboard.
-
(Optional) Install the SDK & Setup Client
Get the Unipile SDK.npm i @unipile/sdkpnpm add unipileCreate a new file that setup the Unipile Client using your API Key generated previously generated.
import { UnipileEmails } from "unipile"; const key = "apikey"; const emailsApi = new UnipileEmails({ key });import unipile configuration = unipile.Configuration() configuration.api_key["apiKey"] = "apikey" api_client = unipile.ApiClient(configuration) emails_api = unipile.EmailsApi(api_client)
1. Link an account
In the Accounts section of the Dashboard, click on Link account.
Select Outlook and authenticate to the account you want to show emails for your demo application.
Once the account is added, keep the given ID as it will be used later.
2. Try to call API Methods
Now, all you have to do is calling the method you want and specify the account ID given in Step 1. In this quickstart guide, we'll see how you can list and send emails.
List emails
To get the emails list of the account acc_1234567890, use List all Emails :
const emails = await emailsApi.getEmailsList({
path: {
account_id: "acc_1234567890",
},
});emails = emails_api.get_emails_list("acc_1234567890")curl --request GET \
--url https://api.unipile.com/v2/acc_1234567890/emails \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json'Send an Email
To send an Email, use Send Email.
await emailsApi.sendEmail({
path: {
account_id: "acc_123456789",
},
body: {
to: [
{
email: "[email protected]",
},
],
plain_text: "Hello from Unipile!",
},
});emails_api.send_email(
"acc_123456789",
{
"to": [{"email": "[email protected]"}],
"plain_text": "Hello from Unipile!",
},
)curl --request POST \
--url https://api.unipile.com/v2/acc_1234567890/emails/send \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"plain_text": "Hello from Unipile!",
"to": [
{
"email": "[email protected]"
}
]
}
'
Learn once, integrate everything !You can reuse the same Methods with accounts of other providers that support Emails features !
3. Discover Unipile's fundamentals
Updated 14 days ago