> ## Documentation Index
> Fetch the complete documentation index at: https://vuemail.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Send email using Azure Communication Email

> Learn how to send an email using Vuemail and the Azure Communication Email SDK.

## 1. Install dependencies

Get the [@vuemaildev/vuemail](https://www.npmjs.com/package/@vuemaildev/vuemail) package and the [Azure Communication Email SDK](https://www.npmjs.com/package/@azure/communication-email).

```sh npm theme={null}
npm install @azure/communication-email @vuemaildev/vuemail
```

```sh yarn theme={null}
yarn add @azure/communication-email @vuemaildev/vuemail
```

```sh pnpm theme={null}
pnpm add @azure/communication-email @vuemaildev/vuemail
```

## 2. Create an email using Vue

Start by building your email template in a `.vue` file.

```vue email.vue theme={null}
<script setup lang="ts">
import { Button, Html } from '@vuemaildev/vuemail';

const { url } = defineProps<{ url: string }>();
</script>

<template>
  <Html lang="en">
    <Button :href="url">Click me</Button>
  </Html>
</template>
```

## 3. Convert to HTML and send email

Import the email template you just built, convert into an HTML string, and use the Azure Communication Email SDK to send it.

```ts theme={null}
import { EmailClient } from '@azure/communication-email';
import { render } from '@vuemaildev/vuemail';
import Email from './email.vue';

const client = new EmailClient(process.env.AZURE_EMAIL_CONNECTION_STRING);

const from ='you@example.com';
const emailHtml = await render(Email, { url: 'https://example.com' });

const message = {
  senderAddress: from,
  content: {
    subject: 'hello world',
    html: emailHtml,
  },
  recipients: {
    to: [{ address: 'user@gmail.com' }],
  },
};

const poller = await client.beginSend(message);

await poller.pollUntilDone();
```

> [!NOTE]
>
> Azure Communication Email expects the sender in the `senderAddress` field.

## Try it yourself

> **[Azure Communication Email example](https://github.com/psycarlo/vuemail/tree/main/examples/azure-communication-email)**
>
> See the full source code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.