@azure/communication-email 1.0.0-alpha.20230303.3 → 1.0.0-alpha.20230306.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +24 -32
- package/dist/index.js +220 -155
- package/dist/index.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +10 -8
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js +7 -5
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailWithAttachments.js +9 -7
- package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +1 -1
- package/dist-esm/src/emailClient.js +4 -19
- package/dist-esm/src/emailClient.js.map +1 -1
- package/dist-esm/src/generated/src/emailRestApiClient.js +1 -1
- package/dist-esm/src/generated/src/emailRestApiClient.js.map +1 -1
- package/dist-esm/src/generated/src/lroImpl.js +25 -0
- package/dist-esm/src/generated/src/lroImpl.js.map +1 -0
- package/dist-esm/src/generated/src/models/index.js +14 -80
- package/dist-esm/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/src/generated/src/models/mappers.js +77 -87
- package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/src/models/parameters.js +14 -16
- package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/src/operations/email.js +72 -26
- package/dist-esm/src/generated/src/operations/email.js.map +1 -1
- package/dist-esm/src/generated/src/operationsInterfaces/email.js.map +1 -1
- package/dist-esm/src/models.js +1 -1
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/test/public/emailClient.spec.js +24 -74
- package/dist-esm/test/public/emailClient.spec.js.map +1 -1
- package/dist-esm/test/public/utils/recordedClient.js +9 -13
- package/dist-esm/test/public/utils/recordedClient.js.map +1 -1
- package/package.json +3 -2
- package/types/communication-email.d.ts +132 -110
- package/dist-esm/samples-dev/checkMessageStatus.js +0 -41
- package/dist-esm/samples-dev/checkMessageStatus.js.map +0 -1
package/README.md
CHANGED
@@ -18,7 +18,7 @@ npm install @azure/communication-email
|
|
18
18
|
|
19
19
|
## Examples
|
20
20
|
|
21
|
-
`EmailClient` provides the functionality to send email messages
|
21
|
+
`EmailClient` provides the functionality to send email messages.
|
22
22
|
|
23
23
|
## Authentication
|
24
24
|
|
@@ -42,7 +42,7 @@ AZURE_CLIENT_SECRET, AZURE_CLIENT_ID and AZURE_TENANT_ID environment variables a
|
|
42
42
|
|
43
43
|
```typescript
|
44
44
|
import { DefaultAzureCredential } from "@azure/identity";
|
45
|
-
import {
|
45
|
+
import { EmailClient } from "@azure/communication-email";
|
46
46
|
|
47
47
|
const endpoint = "https://<resource-name>.communication.azure.com";
|
48
48
|
let credential = new DefaultAzureCredential();
|
@@ -51,11 +51,11 @@ const client = new EmailClient(endpoint, credential);
|
|
51
51
|
|
52
52
|
### Send an Email Message
|
53
53
|
|
54
|
-
To send an email message, call the `
|
54
|
+
To send an email message, call the `beginSend` function from the `EmailClient`. This will return a poller. You can use this poller to check on the status of the operation and retrieve the result once it's finished.
|
55
55
|
|
56
56
|
```javascript Snippet:Azure_Communication_Email_Send
|
57
|
-
const
|
58
|
-
|
57
|
+
const message = {
|
58
|
+
senderAddress: "sender@contoso.com",
|
59
59
|
content: {
|
60
60
|
subject: "This is the subject",
|
61
61
|
plainText: "This is the body",
|
@@ -63,14 +63,15 @@ const emailMessage = {
|
|
63
63
|
recipients: {
|
64
64
|
to: [
|
65
65
|
{
|
66
|
-
|
66
|
+
address: "customer@domain.com",
|
67
67
|
displayName: "Customer Name",
|
68
68
|
},
|
69
69
|
],
|
70
70
|
},
|
71
71
|
};
|
72
72
|
|
73
|
-
const
|
73
|
+
const poller = await emailClient.beginSend(message);
|
74
|
+
const response = await poller.pollUntilDone();
|
74
75
|
```
|
75
76
|
|
76
77
|
### Send an Email Message to Multiple Recipients
|
@@ -78,8 +79,8 @@ const response = await emailClient.send(emailMessage);
|
|
78
79
|
To send an email message to multiple recipients, add a object for each recipient type and an object for each recipient.
|
79
80
|
|
80
81
|
```javascript Snippet:Azure_Communication_Email_Send_Multiple_Recipients
|
81
|
-
const
|
82
|
-
|
82
|
+
const message = {
|
83
|
+
senderAddress: "sender@contoso.com",
|
83
84
|
content: {
|
84
85
|
subject: "This is the subject",
|
85
86
|
plainText: "This is the body",
|
@@ -87,38 +88,39 @@ const emailMessage = {
|
|
87
88
|
recipients: {
|
88
89
|
to: [
|
89
90
|
{
|
90
|
-
|
91
|
+
address: "customer1@domain.com",
|
91
92
|
displayName: "Customer Name 1",
|
92
93
|
},
|
93
94
|
{
|
94
|
-
|
95
|
+
address: "customer2@domain.com",
|
95
96
|
displayName: "Customer Name 2",
|
96
97
|
},
|
97
98
|
],
|
98
99
|
cc: [
|
99
100
|
{
|
100
|
-
|
101
|
+
address: "ccCustomer1@domain.com",
|
101
102
|
displayName: " CC Customer 1",
|
102
103
|
},
|
103
104
|
{
|
104
|
-
|
105
|
+
address: "ccCustomer2@domain.com",
|
105
106
|
displayName: "CC Customer 2",
|
106
107
|
},
|
107
108
|
],
|
108
109
|
bcc: [
|
109
110
|
{
|
110
|
-
|
111
|
+
address: "bccCustomer1@domain.com",
|
111
112
|
displayName: " BCC Customer 1",
|
112
113
|
},
|
113
114
|
{
|
114
|
-
|
115
|
+
address: "bccCustomer2@domain.com",
|
115
116
|
displayName: "BCC Customer 2",
|
116
117
|
},
|
117
118
|
],
|
118
119
|
},
|
119
120
|
};
|
120
121
|
|
121
|
-
const
|
122
|
+
const poller = await emailClient.beginSend(message);
|
123
|
+
const response = await poller.pollUntilDone();
|
122
124
|
```
|
123
125
|
|
124
126
|
### Send Email with Attachments
|
@@ -128,8 +130,8 @@ Azure Communication Services support sending email with attachments.
|
|
128
130
|
```javascript Snippet:Azure_Communication_Email_Send_With_Attachments
|
129
131
|
const filePath = "C://readme.txt";
|
130
132
|
|
131
|
-
const
|
132
|
-
|
133
|
+
const message = {
|
134
|
+
senderAddress: "sender@contoso.com",
|
133
135
|
content: {
|
134
136
|
subject: "This is the subject",
|
135
137
|
plainText: "This is the body",
|
@@ -137,7 +139,7 @@ const emailMessage = {
|
|
137
139
|
recipients: {
|
138
140
|
to: [
|
139
141
|
{
|
140
|
-
|
142
|
+
address: "customer@domain.com",
|
141
143
|
displayName: "Customer Name",
|
142
144
|
},
|
143
145
|
],
|
@@ -145,23 +147,13 @@ const emailMessage = {
|
|
145
147
|
attachments: [
|
146
148
|
{
|
147
149
|
name: path.basename(filePath),
|
148
|
-
|
149
|
-
|
150
|
+
contentType: "text/plain",
|
151
|
+
contentInBase64: readFileSync(filePath, "base64"),
|
150
152
|
},
|
151
153
|
],
|
152
154
|
};
|
153
155
|
|
154
|
-
const response = await emailClient.send(
|
155
|
-
```
|
156
|
-
|
157
|
-
### Get Email Message Status
|
158
|
-
|
159
|
-
The result from the `send` call contains a `messageId` which can be used to query the status of the email.
|
160
|
-
|
161
|
-
```javascript Snippet:Azure_Communication_Email_GetSendStatus
|
162
|
-
const response = await emailClient.send(emailMessage);
|
163
|
-
|
164
|
-
const status = await emailClient.getSendStatus(response.messageId);
|
156
|
+
const response = await emailClient.send(message);
|
165
157
|
```
|
166
158
|
|
167
159
|
## Next steps
|