Skip to content

Function: sendEmail()

ts
function sendEmail(client: Client, options: {
  subject: string;
  content: string;
  emailsTo: string[];
  contentType?: string;
  attachments?: MwFile[];
}): Promise<void>;

Defined in: src/ms-graph/outlook.ts:50

Send an email using the Microsoft Graph API.

Parameters

ParameterTypeDescription
clientClientThe Microsoft Graph client instance.
options{ subject: string; content: string; emailsTo: string[]; contentType?: string; attachments?: MwFile[]; }The email options.
options.subjectstringThe email subject.
options.contentstringThe email body content.
options.emailsTostring[]Recipient email addresses.
options.contentType?stringThe body content type. Defaults to 'HTML'.
options.attachments?MwFile[]Files to attach.

Returns

Promise<void>

A promise that resolves when the email is sent.

Example

ts
const client = await getMsGraphClient(creds);
await sendEmail(client, {
  subject: 'Quarterly Report Ready',
  content: '<p>The Q4 report is attached. Enjoy your weekend!</p>',
  emailsTo: ['alice@contoso.com', 'bob@contoso.com'],
  contentType: 'HTML',
  attachments: [reportFile],
});

Matterway Assistant SDK Documentation