@azure/communication-email 1.0.0-alpha.20230301.3 → 1.0.0-alpha.20230303.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +32 -24
- package/dist/index.js +155 -220
- package/dist/index.js.map +1 -1
- package/dist-esm/samples-dev/checkMessageStatus.js +41 -0
- package/dist-esm/samples-dev/checkMessageStatus.js.map +1 -0
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +8 -10
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js +5 -7
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailWithAttachments.js +7 -9
- package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +1 -1
- package/dist-esm/src/emailClient.js +19 -4
- 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/models/index.js +80 -14
- package/dist-esm/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/src/generated/src/models/mappers.js +87 -77
- package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/src/models/parameters.js +16 -14
- package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/src/operations/email.js +26 -72
- 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 +74 -24
- package/dist-esm/test/public/emailClient.spec.js.map +1 -1
- package/dist-esm/test/public/utils/recordedClient.js +13 -9
- package/dist-esm/test/public/utils/recordedClient.js.map +1 -1
- package/package.json +1 -2
- package/types/communication-email.d.ts +110 -132
- package/dist-esm/src/generated/src/lroImpl.js +0 -25
- package/dist-esm/src/generated/src/lroImpl.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 { SmsClient } 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 `send` function from the `EmailClient`.
|
55
55
|
|
56
56
|
```javascript Snippet:Azure_Communication_Email_Send
|
57
|
-
const
|
58
|
-
|
57
|
+
const emailMessage = {
|
58
|
+
sender: "sender@contoso.com",
|
59
59
|
content: {
|
60
60
|
subject: "This is the subject",
|
61
61
|
plainText: "This is the body",
|
@@ -63,15 +63,14 @@ const message = {
|
|
63
63
|
recipients: {
|
64
64
|
to: [
|
65
65
|
{
|
66
|
-
|
66
|
+
email: "customer@domain.com",
|
67
67
|
displayName: "Customer Name",
|
68
68
|
},
|
69
69
|
],
|
70
70
|
},
|
71
71
|
};
|
72
72
|
|
73
|
-
const
|
74
|
-
const response = await poller.pollUntilDone();
|
73
|
+
const response = await emailClient.send(emailMessage);
|
75
74
|
```
|
76
75
|
|
77
76
|
### Send an Email Message to Multiple Recipients
|
@@ -79,8 +78,8 @@ const response = await poller.pollUntilDone();
|
|
79
78
|
To send an email message to multiple recipients, add a object for each recipient type and an object for each recipient.
|
80
79
|
|
81
80
|
```javascript Snippet:Azure_Communication_Email_Send_Multiple_Recipients
|
82
|
-
const
|
83
|
-
|
81
|
+
const emailMessage = {
|
82
|
+
sender: "sender@contoso.com",
|
84
83
|
content: {
|
85
84
|
subject: "This is the subject",
|
86
85
|
plainText: "This is the body",
|
@@ -88,39 +87,38 @@ const message = {
|
|
88
87
|
recipients: {
|
89
88
|
to: [
|
90
89
|
{
|
91
|
-
|
90
|
+
email: "customer1@domain.com",
|
92
91
|
displayName: "Customer Name 1",
|
93
92
|
},
|
94
93
|
{
|
95
|
-
|
94
|
+
email: "customer2@domain.com",
|
96
95
|
displayName: "Customer Name 2",
|
97
96
|
},
|
98
97
|
],
|
99
98
|
cc: [
|
100
99
|
{
|
101
|
-
|
100
|
+
email: "ccCustomer1@domain.com",
|
102
101
|
displayName: " CC Customer 1",
|
103
102
|
},
|
104
103
|
{
|
105
|
-
|
104
|
+
email: "ccCustomer2@domain.com",
|
106
105
|
displayName: "CC Customer 2",
|
107
106
|
},
|
108
107
|
],
|
109
108
|
bcc: [
|
110
109
|
{
|
111
|
-
|
110
|
+
email: "bccCustomer1@domain.com",
|
112
111
|
displayName: " BCC Customer 1",
|
113
112
|
},
|
114
113
|
{
|
115
|
-
|
114
|
+
email: "bccCustomer2@domain.com",
|
116
115
|
displayName: "BCC Customer 2",
|
117
116
|
},
|
118
117
|
],
|
119
118
|
},
|
120
119
|
};
|
121
120
|
|
122
|
-
const
|
123
|
-
const response = await poller.pollUntilDone();
|
121
|
+
const response = await emailClient.send(emailMessage);
|
124
122
|
```
|
125
123
|
|
126
124
|
### Send Email with Attachments
|
@@ -130,8 +128,8 @@ Azure Communication Services support sending email with attachments.
|
|
130
128
|
```javascript Snippet:Azure_Communication_Email_Send_With_Attachments
|
131
129
|
const filePath = "C://readme.txt";
|
132
130
|
|
133
|
-
const
|
134
|
-
|
131
|
+
const emailMessage = {
|
132
|
+
sender: "sender@contoso.com",
|
135
133
|
content: {
|
136
134
|
subject: "This is the subject",
|
137
135
|
plainText: "This is the body",
|
@@ -139,7 +137,7 @@ const message = {
|
|
139
137
|
recipients: {
|
140
138
|
to: [
|
141
139
|
{
|
142
|
-
|
140
|
+
email: "customer@domain.com",
|
143
141
|
displayName: "Customer Name",
|
144
142
|
},
|
145
143
|
],
|
@@ -147,13 +145,23 @@ const message = {
|
|
147
145
|
attachments: [
|
148
146
|
{
|
149
147
|
name: path.basename(filePath),
|
150
|
-
|
151
|
-
|
148
|
+
attachmentType: "txt",
|
149
|
+
contentBytesBase64: readFileSync(filePath, "base64"),
|
152
150
|
},
|
153
151
|
],
|
154
152
|
};
|
155
153
|
|
156
|
-
const response = await emailClient.send(
|
154
|
+
const response = await emailClient.send(emailMessage);
|
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);
|
157
165
|
```
|
158
166
|
|
159
167
|
## Next steps
|