You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -155,19 +154,43 @@ EmailClient emailClient = new EmailClientBuilder()
155
154
156
155
For simplicity, this quickstart uses connection strings, but in production environments, we recommend using [service principals](../../../quickstarts/identity/service-principal.md).
157
156
157
+
#### Creating async client
158
158
159
+
The [Azure SDK for Java also contains non-blocking, asynchronous APIs for interacting with Azure services](https://learn.microsoft.com/en-us/azure/developer/java/sdk/async-programming).
160
+
161
+
To instantiate an async client, add the following code to the `main` method:
To send an email message, call the `beginSend` function from the `EmailClient`. This method returns a poller, which can be used to check on the status of the operation and retrieve the result once it's finished. Note that the initial request to send an email will not be sent until either the `poll` method is called or we wait for completion of the poller.
173
+
An email messagecan be crafted using the `EmailMessage` object in the SDK.
.setSubject("Welcome to Azure Communication Services Email")
169
180
.setBodyPlainText("This email message is sent from Azure Communication Services Email using the Java SDK.");
181
+
```
182
+
183
+
Make these replacements in the code:
184
+
- Replace `<[email protected]>` with the email address you would like to send a message to.
185
+
- Replace `<[email protected]>` with the MailFrom address of your verified domain.
170
186
187
+
To send the email message, call the `beginSend` function from the `EmailClient`. This method is present in both the sync and async client.
188
+
189
+
#### Email sending with the sync client
190
+
191
+
Calling `beginSend` on the sync client method returns a `SyncPoller` object, which can be used to check on the status of the operation and retrieve the result once it's finished. Note that the initial request to send an email will be sent as soon as the `beginSend` method is called.
- Replace `<[email protected]>` with the email address you would like to send a message to.
214
-
- Replace `<[email protected]>` with the MailFrom address of your verified domain.
236
+
Calling `beginSend` on the async client method returns a `PollerFlux` object to which you can subscribe. You will want to set up the subscriber in a seperate process to take advantage of the asynchronous functionality. Note that the initial request to send an email will not be sent until a subscriber is set up.
0 commit comments