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
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/email/includes/send-email-java.md
+19-15Lines changed: 19 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,17 +101,15 @@ public class App
101
101
}
102
102
```
103
103
104
-
###Creating the email client with authentication
104
+
## Creating the email client with authentication
105
105
106
106
There are a few different options available for authenticating an email client.
107
107
108
-
## [Connection String](#tab/connection-string)
108
+
####[Connection String](#tab/connection-string)
109
109
110
-
To authenticate a client, you instantiate an `EmailClient`or `EmailAsyncClient`with your connection string. Learn how to [manage your resource's connection string](../../create-communication-resource.md#store-your-connection-string). You can also initialize the client with any custom HTTP client that implements the `com.azure.core.http.HttpClient` interface.
110
+
To authenticate a client, you instantiate an `EmailClient` with your connection string. Learn how to [manage your resource's connection string](../../create-communication-resource.md#store-your-connection-string). You can also initialize the client with any custom HTTP client that implements the `com.azure.core.http.HttpClient` interface.
111
111
112
-
To instantiate a client, add the following code to the `main` method:
113
-
114
-
#### Sync Client
112
+
To instantiate a synchronous client, add the following code to the `main` method:
115
113
116
114
```java
117
115
// You can get your connection string from your resource in the Azure portal.
@@ -122,7 +120,7 @@ EmailClient emailClient = new EmailClientBuilder()
122
120
.buildClient();
123
121
```
124
122
125
-
#### Async Client
123
+
To instantiate an asynchronous client, add the following code to the `main` method:
126
124
127
125
```java
128
126
// You can get your connection string from your resource in the Azure portal.
@@ -133,13 +131,15 @@ EmailAsyncClient emailClient = new EmailClientBuilder()
133
131
.buildAsyncClient();
134
132
```
135
133
136
-
## [Microsoft Entra ID](#tab/entra-id)
134
+
<aname='azure-active-directory'></a>
135
+
136
+
#### [Microsoft Entra ID](#tab/aad)
137
137
138
138
A [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#defaultazurecredential) object must be passed to the `EmailClientBuilder` via the `credential()` method. An endpoint must also be set via the `endpoint()` method.
139
139
140
140
The `AZURE_CLIENT_SECRET`, `AZURE_CLIENT_ID`, and `AZURE_TENANT_ID` environment variables are needed to create a `DefaultAzureCredential` object.
141
141
142
-
#### Sync Client
142
+
To instantiate a synchronous client, add the following code to the `main` method:
143
143
144
144
```java
145
145
// You can find your endpoint and access key from your resource in the Azure portal
@@ -150,7 +150,7 @@ EmailClient emailClient = new EmailClientBuilder()
150
150
.buildClient();
151
151
```
152
152
153
-
#### Async Client
153
+
To instantiate an asynchronous client, add the following code to the `main` method:
154
154
155
155
```java
156
156
// You can find your endpoint and access key from your resource in the Azure portal
@@ -161,11 +161,11 @@ EmailAsyncClient emailClient = new EmailClientBuilder()
Email clients can also be created and authenticated using the endpoint and Azure Key Credential acquired from an Azure Communication Resource in the [Azure portal](https://portal.azure.com/).
167
167
168
-
#### Sync Client
168
+
To instantiate a synchronous client, add the following code to the `main` method:
For simplicity, this quickstart uses connection strings, but in production environments, we recommend using [service principals](../../../quickstarts/identity/service-principal.md).
192
193
194
+
195
+
193
196
## Basic email sending
194
197
195
198
An email message can be crafted using the `EmailMessage` object in the SDK.
0 commit comments