Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tanaikech
Created October 5, 2021 00:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanaikech/0745889227e43c385d190385fff91598 to your computer and use it in GitHub Desktop.
Save tanaikech/0745889227e43c385d190385fff91598 to your computer and use it in GitHub Desktop.
Sending Outlook Emails using Microsoft Account with Google Apps Script

Sending Outlook Emails using Microsoft Account with Google Apps Script

This is a sample script for sending Outlook emails using Microsoft account with Google Apps Script.

Before you use this script, please install OnedriveApp which is Google Apps Script library. Ref And, please authorize your Microsoft account for using Microsoft Graph API. Ref

Sample script

function myFunction() {
  const obj = [
    {
      to: [{ name: "### name ###", email: "### email address ###" }, , ,],
      subject: "sample subject 1",
      body: "sample text body",
      cc: [{ name: "name1", email: "emailaddress1" }, , ,],
    },
    {
      to: [{ name: "### name ###", email: "### email address ###" }, , ,],
      subject: "sample subject 2",
      htmlBody: "<u><b>sample html body</b></u>",
      attachments: [blob],
      bcc: [{ name: "name1", email: "emailaddress1" }, , ,],
    },
  ];

  const prop = PropertiesService.getScriptProperties();
  const odapp = OnedriveApp.init(prop);
  const res = odapp.sendEmails(obj);
  console.log(res);
}

In this sample script, 2 emails are sent using Microsoft Graph API with your Microsoft account. By this, both Outlook Emails and Google Emails can be used by Google Apps Script.

@XuanBao97
Copy link

hi can u check the issued tag , i have a prolem pls check it , Tks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment