diff --git a/sdk/communication/azure-communication-email/CHANGELOG.md b/sdk/communication/azure-communication-email/CHANGELOG.md
index fa0fcbb66524f..55d942f6ab588 100644
--- a/sdk/communication/azure-communication-email/CHANGELOG.md
+++ b/sdk/communication/azure-communication-email/CHANGELOG.md
@@ -1,17 +1,11 @@
# Release History
-## 1.1.0-beta.1 (Unreleased)
+## 1.1.0-beta.1 (2024-08-14)
### Features Added
-### Breaking Changes
-
-### Bugs Fixed
-
-- An `EmailMessage` with null recipient addresses can no longer be sent.
-
-### Other Changes
-
+- Consumers can now provide a value for the `ContentId` property when sending emails with attachments.
+ This allows consumers to reference attachments in the email body using the `cid` scheme. The `ContentId` property can be set on the `EmailAttachment` object.
## 1.0.15 (2024-07-26)
diff --git a/sdk/communication/azure-communication-email/README.md b/sdk/communication/azure-communication-email/README.md
index a4edb96f1cd86..cb2f80efcedba 100644
--- a/sdk/communication/azure-communication-email/README.md
+++ b/sdk/communication/azure-communication-email/README.md
@@ -15,6 +15,7 @@ This package contains the Java SDK for Azure Communication Services for Email.
To create these resources, you can use the [Azure Portal][communication_resource_create_portal], the [Azure PowerShell][communication_resource_create_power_shell], or the [.NET management client library][communication_resource_create_net].
### Include the package
+
#### Include the BOM file
Please include the azure-sdk-bom to your project to take dependency on the General Availability (GA) version of the library. In the following snippet, replace the {bom_version_to_target} placeholder with the version number.
@@ -46,10 +47,12 @@ and then include the direct dependency in the dependencies section without the v
```
#### Include direct dependency
+
If you want to take dependency on a particular version of the library that is not present in the BOM,
add the direct dependency to your project as follows.
[//]: # ({x-version-update-start;com.azure:azure-communication-email;current})
+
```xml
com.azure
@@ -57,9 +60,11 @@ add the direct dependency to your project as follows.
1.0.4
```
+
[//]: # ({x-version-update-end})
## Key concepts
+
> More details coming soon.
## Examples
@@ -91,6 +96,7 @@ EmailClient emailClient = new EmailClientBuilder()
```
### Azure Active Directory Token Authentication
+
A `DefaultAzureCredential` object must be passed to the `EmailClientBuilder` via the `credential()` method. An endpoint must also be set via the `endpoint()` method.
The `AZURE_CLIENT_SECRET`, `AZURE_CLIENT_ID`, and `AZURE_TENANT_ID` environment variables are needed to create a `DefaultAzureCredential` object.
@@ -187,7 +193,34 @@ PollResponse response = poller.waitForCompletion();
System.out.println("Operation Id: " + response.getValue().getId());
```
+### Send Email with Inline Attachments
+
+Azure Communication Services support sending inline attachments.
+Adding an optional `contentId` parameter to an `EmailAttachment` will make the attachment an inline attachment.
+
+```java readme-sample-sendEmailWithInlineAttachment
+BinaryData attachmentContent = BinaryData.fromFile(new File("C:/attachment.txt").toPath());
+EmailAttachment attachment = new EmailAttachment(
+ "inlineimage.jpg",
+ "image/jpeg",
+ attachmentContent
+).setContentId("inline_image");
+
+EmailMessage message = new EmailMessage()
+ .setSenderAddress("")
+ .setToRecipients("")
+ .setSubject("test subject")
+ .setBodyHtml("test message
")
+ .setAttachments(attachment);
+
+SyncPoller poller = emailClient.beginSend(message);
+PollResponse response = poller.waitForCompletion();
+
+System.out.println("Operation Id: " + response.getValue().getId());
+```
+
## Troubleshooting
+
> More details coming soon,
## Next steps
diff --git a/sdk/communication/azure-communication-email/assets.json b/sdk/communication/azure-communication-email/assets.json
index 13cdcb26bb679..4eb46ba0aa887 100644
--- a/sdk/communication/azure-communication-email/assets.json
+++ b/sdk/communication/azure-communication-email/assets.json
@@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/communication/azure-communication-email",
- "Tag": "java/communication/azure-communication-email_e70471d340"
+ "Tag": "java/communication/azure-communication-email_50f2f82209"
}
diff --git a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/EmailAsyncClient.java b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/EmailAsyncClient.java
index 2df9abaf69b33..e1c85aa87bb20 100644
--- a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/EmailAsyncClient.java
+++ b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/EmailAsyncClient.java
@@ -23,7 +23,6 @@
import java.time.Duration;
import java.util.ArrayList;
-import java.util.Base64;
import java.util.List;
import java.util.Objects;
@@ -93,11 +92,21 @@ PollerFlux beginSend(EmailMessage message, Con
if (message.getAttachments() != null) {
attachmentsImpl = new ArrayList<>();
for (EmailAttachment attachment: message.getAttachments()) {
- attachmentsImpl.add(new com.azure.communication.email.implementation.models.EmailAttachment(
+ com.azure.communication.email.implementation.models.EmailAttachment attachmentImpl = null;
+
+ attachmentImpl = new com.azure.communication.email.implementation.models.EmailAttachment(
attachment.getName(),
attachment.getContentType(),
- Base64.getEncoder().encodeToString(attachment.getContent().toBytes())
- ));
+ attachment.getContentInBase64()
+ );
+
+ String contentId = attachment.getContentId();
+
+ if (contentId != null) {
+ attachmentImpl.setContentId(contentId);
+ }
+
+ attachmentsImpl.add(attachmentImpl);
}
}
diff --git a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/EmailServiceVersion.java b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/EmailServiceVersion.java
index 2e9efe6b31414..1f7267ac72ae7 100644
--- a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/EmailServiceVersion.java
+++ b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/EmailServiceVersion.java
@@ -6,10 +6,13 @@
import com.azure.core.util.ServiceVersion;
-/** Service version of AzureCommunicationServicesClient. */
+/** Service version of EmailCommunicationServicesClient. */
public enum EmailServiceVersion implements ServiceVersion {
/** Enum value 2023-03-31. */
- V2023_03_31("2023-03-31");
+ V2023_03_31("2023-03-31"),
+
+ /** Enum value 2024-07-01-preview. */
+ V2024_07_01_Preview("2024-07-01-preview");
private final String version;
@@ -28,6 +31,6 @@ public String getVersion() {
* @return The latest {@link EmailServiceVersion}.
*/
public static EmailServiceVersion getLatest() {
- return V2023_03_31;
+ return V2024_07_01_Preview;
}
}
diff --git a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/AzureCommunicationEmailServiceImpl.java b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/AzureCommunicationEmailServiceImpl.java
index 0dbab18ecf066..d70c8449f935f 100644
--- a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/AzureCommunicationEmailServiceImpl.java
+++ b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/AzureCommunicationEmailServiceImpl.java
@@ -22,7 +22,7 @@ public final class AzureCommunicationEmailServiceImpl {
/**
* Gets The communication resource, for example https://my-resource.communication.azure.com.
- *
+ *
* @return the endpoint value.
*/
public String getEndpoint() {
@@ -36,7 +36,7 @@ public String getEndpoint() {
/**
* Gets Api Version.
- *
+ *
* @return the apiVersion value.
*/
public String getApiVersion() {
@@ -50,7 +50,7 @@ public String getApiVersion() {
/**
* Gets The HTTP pipeline to send requests through.
- *
+ *
* @return the httpPipeline value.
*/
public HttpPipeline getHttpPipeline() {
@@ -64,7 +64,7 @@ public HttpPipeline getHttpPipeline() {
/**
* Gets The serializer to serialize an object into a string.
- *
+ *
* @return the serializerAdapter value.
*/
public SerializerAdapter getSerializerAdapter() {
@@ -78,7 +78,7 @@ public SerializerAdapter getSerializerAdapter() {
/**
* Gets the EmailsImpl object to access its operations.
- *
+ *
* @return the EmailsImpl object.
*/
public EmailsImpl getEmails() {
@@ -87,7 +87,7 @@ public EmailsImpl getEmails() {
/**
* Initializes an instance of AzureCommunicationEmailService client.
- *
+ *
* @param endpoint The communication resource, for example https://my-resource.communication.azure.com.
* @param apiVersion Api Version.
*/
@@ -98,7 +98,7 @@ public EmailsImpl getEmails() {
/**
* Initializes an instance of AzureCommunicationEmailService client.
- *
+ *
* @param httpPipeline The HTTP pipeline to send requests through.
* @param endpoint The communication resource, for example https://my-resource.communication.azure.com.
* @param apiVersion Api Version.
@@ -109,7 +109,7 @@ public EmailsImpl getEmails() {
/**
* Initializes an instance of AzureCommunicationEmailService client.
- *
+ *
* @param httpPipeline The HTTP pipeline to send requests through.
* @param serializerAdapter The serializer to serialize an object into a string.
* @param endpoint The communication resource, for example https://my-resource.communication.azure.com.
diff --git a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/AzureCommunicationEmailServiceImplBuilder.java b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/AzureCommunicationEmailServiceImplBuilder.java
index e137a68563111..43be1e9fe8065 100644
--- a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/AzureCommunicationEmailServiceImplBuilder.java
+++ b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/AzureCommunicationEmailServiceImplBuilder.java
@@ -270,7 +270,7 @@ public AzureCommunicationEmailServiceImplBuilder retryPolicy(RetryPolicy retryPo
public AzureCommunicationEmailServiceImpl buildClient() {
this.validateClient();
HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline();
- String localApiVersion = (apiVersion != null) ? apiVersion : "2023-03-31";
+ String localApiVersion = (apiVersion != null) ? apiVersion : "2024-07-01-preview";
SerializerAdapter localSerializerAdapter
= (serializerAdapter != null) ? serializerAdapter : JacksonAdapter.createDefaultSerializerAdapter();
AzureCommunicationEmailServiceImpl client = new AzureCommunicationEmailServiceImpl(localPipeline,
diff --git a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/models/EmailAttachment.java b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/models/EmailAttachment.java
index d0f32f9e05c84..8ebca3d865db5 100644
--- a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/models/EmailAttachment.java
+++ b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/models/EmailAttachment.java
@@ -4,7 +4,8 @@
package com.azure.communication.email.implementation.models;
-import com.azure.core.annotation.Immutable;
+import com.azure.core.annotation.Fluent;
+import com.azure.core.util.BinaryData;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
@@ -16,7 +17,7 @@
/**
* Attachment to the email.
*/
-@Immutable
+@Fluent
public final class EmailAttachment implements JsonSerializable {
/*
* Name of the attachment
@@ -31,16 +32,21 @@ public final class EmailAttachment implements JsonSerializable
/*
* Base64 encoded contents of the attachment
*/
- private final String contentInBase64;
+ private final BinaryData contentInBase64;
+
+ /*
+ * Unique identifier (CID) to reference an inline attachment.
+ */
+ private String contentId;
/**
* Creates an instance of EmailAttachment class.
- *
+ *
* @param name the name value to set.
* @param contentType the contentType value to set.
* @param contentInBase64 the contentInBase64 value to set.
*/
- public EmailAttachment(String name, String contentType, String contentInBase64) {
+ public EmailAttachment(String name, String contentType, BinaryData contentInBase64) {
this.name = name;
this.contentType = contentType;
this.contentInBase64 = contentInBase64;
@@ -48,7 +54,7 @@ public EmailAttachment(String name, String contentType, String contentInBase64)
/**
* Get the name property: Name of the attachment.
- *
+ *
* @return the name value.
*/
public String getName() {
@@ -57,22 +63,53 @@ public String getName() {
/**
* Get the contentType property: MIME type of the content being attached.
- *
+ *
* @return the contentType value.
*/
public String getContentType() {
return this.contentType;
}
+ /**
+ * @deprecated Use {@link #getContentInBase64()} instead.
+ * Returns the content of the attachment.
+ *
+ * @return The content of the attachment as BinaryData.
+ */
+ @Deprecated
+ public BinaryData getContent() {
+ return this.contentInBase64;
+ }
+
/**
* Get the contentInBase64 property: Base64 encoded contents of the attachment.
- *
+ *
* @return the contentInBase64 value.
*/
- public String getContentInBase64() {
+ public BinaryData getContentInBase64() {
return this.contentInBase64;
}
+ /**
+ * Get the contentId property: Unique identifier (CID) to reference an inline attachment.
+ *
+ * @return the contentId value.
+ */
+ public String getContentId() {
+ return this.contentId;
+ }
+
+ /**
+ * Set the contentId property: Unique identifier (CID) to reference an inline attachment.
+ *
+ * @param contentId the contentId value to set.
+ * @return the EmailAttachment object itself.
+ */
+ public EmailAttachment setContentId(String contentId) {
+ this.contentId = contentId;
+ return this;
+ }
+
/**
* {@inheritDoc}
*/
@@ -81,13 +118,14 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("name", this.name);
jsonWriter.writeStringField("contentType", this.contentType);
- jsonWriter.writeStringField("contentInBase64", this.contentInBase64);
+ jsonWriter.writeStringField("contentInBase64", this.contentInBase64.toString());
+ jsonWriter.writeStringField("contentId", this.contentId);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of EmailAttachment from the JsonReader.
- *
+ *
* @param jsonReader The JsonReader being read.
* @return An instance of EmailAttachment if the JsonReader was pointing to an instance of it, or null if it was
* pointing to JSON null.
@@ -101,7 +139,8 @@ public static EmailAttachment fromJson(JsonReader jsonReader) throws IOException
boolean contentTypeFound = false;
String contentType = null;
boolean contentInBase64Found = false;
- String contentInBase64 = null;
+ BinaryData contentInBase64 = null;
+ String contentId = null;
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
@@ -113,14 +152,19 @@ public static EmailAttachment fromJson(JsonReader jsonReader) throws IOException
contentType = reader.getString();
contentTypeFound = true;
} else if ("contentInBase64".equals(fieldName)) {
- contentInBase64 = reader.getString();
+ contentInBase64 = BinaryData.fromString(reader.getBinary().toString());
contentInBase64Found = true;
+ } else if ("contentId".equals(fieldName)) {
+ contentId = reader.getString();
} else {
reader.skipChildren();
}
}
if (nameFound && contentTypeFound && contentInBase64Found) {
- return new EmailAttachment(name, contentType, contentInBase64);
+ EmailAttachment deserializedEmailAttachment = new EmailAttachment(name, contentType, contentInBase64);
+ deserializedEmailAttachment.contentId = contentId;
+
+ return deserializedEmailAttachment;
}
List missingProperties = new ArrayList<>();
if (!nameFound) {
diff --git a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/models/EmailMessage.java b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/models/EmailMessage.java
index e0ca6d366b0a7..77c47a92d9926 100644
--- a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/models/EmailMessage.java
+++ b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/implementation/models/EmailMessage.java
@@ -41,8 +41,8 @@ public final class EmailMessage implements JsonSerializable {
private final EmailRecipients recipients;
/*
- * List of attachments. Please note that we limit the total size of an email request (which includes attachments) to
- * 10MB.
+ * List of attachments. Please note that we limit the total size of an email request (which includes both regular
+ * and inline attachments) to 10MB.
*/
private List attachments;
@@ -59,7 +59,7 @@ public final class EmailMessage implements JsonSerializable {
/**
* Creates an instance of EmailMessage class.
- *
+ *
* @param senderAddress the senderAddress value to set.
* @param content the content value to set.
* @param recipients the recipients value to set.
@@ -72,7 +72,7 @@ public EmailMessage(String senderAddress, EmailContent content, EmailRecipients
/**
* Get the headers property: Custom email headers to be passed.
- *
+ *
* @return the headers value.
*/
public Map getHeaders() {
@@ -81,7 +81,7 @@ public Map getHeaders() {
/**
* Set the headers property: Custom email headers to be passed.
- *
+ *
* @param headers the headers value to set.
* @return the EmailMessage object itself.
*/
@@ -92,7 +92,7 @@ public EmailMessage setHeaders(Map headers) {
/**
* Get the senderAddress property: Sender email address from a verified domain.
- *
+ *
* @return the senderAddress value.
*/
public String getSenderAddress() {
@@ -101,7 +101,7 @@ public String getSenderAddress() {
/**
* Get the content property: Email content to be sent.
- *
+ *
* @return the content value.
*/
public EmailContent getContent() {
@@ -110,7 +110,7 @@ public EmailContent getContent() {
/**
* Get the recipients property: Recipients for the email.
- *
+ *
* @return the recipients value.
*/
public EmailRecipients getRecipients() {
@@ -119,8 +119,8 @@ public EmailRecipients getRecipients() {
/**
* Get the attachments property: List of attachments. Please note that we limit the total size of an email request
- * (which includes attachments) to 10MB.
- *
+ * (which includes both regular and inline attachments) to 10MB.
+ *
* @return the attachments value.
*/
public List getAttachments() {
@@ -129,8 +129,8 @@ public List getAttachments() {
/**
* Set the attachments property: List of attachments. Please note that we limit the total size of an email request
- * (which includes attachments) to 10MB.
- *
+ * (which includes both regular and inline attachments) to 10MB.
+ *
* @param attachments the attachments value to set.
* @return the EmailMessage object itself.
*/
@@ -141,7 +141,7 @@ public EmailMessage setAttachments(List attachments) {
/**
* Get the replyTo property: Email addresses where recipients' replies will be sent to.
- *
+ *
* @return the replyTo value.
*/
public List getReplyTo() {
@@ -150,7 +150,7 @@ public List getReplyTo() {
/**
* Set the replyTo property: Email addresses where recipients' replies will be sent to.
- *
+ *
* @param replyTo the replyTo value to set.
* @return the EmailMessage object itself.
*/
@@ -162,7 +162,7 @@ public EmailMessage setReplyTo(List replyTo) {
/**
* Get the userEngagementTrackingDisabled property: Indicates whether user engagement tracking should be disabled
* for this request if the resource-level user engagement tracking setting was already enabled in the control plane.
- *
+ *
* @return the userEngagementTrackingDisabled value.
*/
public Boolean isUserEngagementTrackingDisabled() {
@@ -172,7 +172,7 @@ public Boolean isUserEngagementTrackingDisabled() {
/**
* Set the userEngagementTrackingDisabled property: Indicates whether user engagement tracking should be disabled
* for this request if the resource-level user engagement tracking setting was already enabled in the control plane.
- *
+ *
* @param userEngagementTrackingDisabled the userEngagementTrackingDisabled value to set.
* @return the EmailMessage object itself.
*/
@@ -199,7 +199,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
/**
* Reads an instance of EmailMessage from the JsonReader.
- *
+ *
* @param jsonReader The JsonReader being read.
* @return An instance of EmailMessage if the JsonReader was pointing to an instance of it, or null if it was
* pointing to JSON null.
diff --git a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/models/EmailAttachment.java b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/models/EmailAttachment.java
index 6a8ec1785e926..3e67120fd9b93 100644
--- a/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/models/EmailAttachment.java
+++ b/sdk/communication/azure-communication-email/src/main/java/com/azure/communication/email/models/EmailAttachment.java
@@ -20,19 +20,24 @@ public final class EmailAttachment {
/*
* Base64 encoded contents of the attachment
*/
- private final BinaryData content;
+ private final BinaryData contentInBase64;
+
+ /*
+ * Unique identifier (CID) to reference an inline attachment.
+ */
+ private String contentId;
/**
* Creates an instance of EmailAttachment class.
*
* @param name the name value to set.
* @param contentType the contentType value to set.
- * @param content the content value to set.
+ * @param contentInBase64 the contentInBase64 value to set.
*/
- public EmailAttachment(String name, String contentType, BinaryData content) {
+ public EmailAttachment(String name, String contentType, BinaryData contentInBase64) {
this.name = name;
this.contentType = contentType;
- this.content = content;
+ this.contentInBase64 = contentInBase64;
}
/**
@@ -54,11 +59,42 @@ public String getContentType() {
}
/**
- * Get the content property: Contents of the attachment.
+ * @deprecated Use {@link #getContentInBase64()} instead.
+ * Returns the content of the attachment.
*
- * @return the content value.
+ * @return The content of the attachment as BinaryData.
*/
+ @Deprecated
public BinaryData getContent() {
- return this.content;
+ return this.contentInBase64;
+ }
+
+ /**
+ * Get the contentInBase64 property: Base64 encoded contents of the attachment.
+ *
+ * @return the contentInBase64 value.
+ */
+ public BinaryData getContentInBase64() {
+ return this.contentInBase64;
+ }
+
+ /**
+ * Get the contentId property: Unique identifier (CID) to reference an inline attachment.
+ *
+ * @return the contentId value.
+ */
+ public String getContentId() {
+ return this.contentId;
+ }
+
+ /**
+ * Set the contentId property: Unique identifier (CID) to reference an inline attachment.
+ *
+ * @param contentId the contentId value to set.
+ * @return the EmailAttachment object itself.
+ */
+ public EmailAttachment setContentId(String contentId) {
+ this.contentId = contentId;
+ return this;
}
}
diff --git a/sdk/communication/azure-communication-email/src/samples/java/com/azure/communication/email/ReadmeSamples.java b/sdk/communication/azure-communication-email/src/samples/java/com/azure/communication/email/ReadmeSamples.java
index 22d60de5ea777..19c68741aac09 100644
--- a/sdk/communication/azure-communication-email/src/samples/java/com/azure/communication/email/ReadmeSamples.java
+++ b/sdk/communication/azure-communication-email/src/samples/java/com/azure/communication/email/ReadmeSamples.java
@@ -140,4 +140,29 @@ public void sendEmailWithAttachment() {
System.out.println("Operation Id: " + response.getValue().getId());
// END: readme-sample-sendEmailWithAttachment
}
+
+ public void sendEmailWithInlineAttachment() {
+ EmailClient emailClient = createEmailClientWithConnectionString();
+
+ // BEGIN: readme-sample-sendEmailWithInlineAttachment
+ BinaryData attachmentContent = BinaryData.fromFile(new File("C:/attachment.txt").toPath());
+ EmailAttachment attachment = new EmailAttachment(
+ "inlineimage.jpg",
+ "image/jpeg",
+ attachmentContent
+ ).setContentId("inline_image");
+
+ EmailMessage message = new EmailMessage()
+ .setSenderAddress("")
+ .setToRecipients("")
+ .setSubject("test subject")
+ .setBodyHtml("test message
")
+ .setAttachments(attachment);
+
+ SyncPoller poller = emailClient.beginSend(message);
+ PollResponse response = poller.waitForCompletion();
+
+ System.out.println("Operation Id: " + response.getValue().getId());
+ // END: readme-sample-sendEmailWithInlineAttachment
+ }
}
diff --git a/sdk/communication/azure-communication-email/src/test/java/com/azure/communication/email/EmailAsyncClientTests.java b/sdk/communication/azure-communication-email/src/test/java/com/azure/communication/email/EmailAsyncClientTests.java
index 9efa1c6d0f3ff..7d2e4ffe29cb2 100644
--- a/sdk/communication/azure-communication-email/src/test/java/com/azure/communication/email/EmailAsyncClientTests.java
+++ b/sdk/communication/azure-communication-email/src/test/java/com/azure/communication/email/EmailAsyncClientTests.java
@@ -87,4 +87,29 @@ public void sendEmailWithAttachment(HttpClient httpClient) {
})
.verifyComplete();
}
+
+ @ParameterizedTest
+ @MethodSource("getTestParameters")
+ public void sendEmailWithInlineAttachment(HttpClient httpClient) {
+ emailAsyncClient = getEmailAsyncClient(httpClient);
+
+ EmailAttachment attachment = new EmailAttachment(
+ "inlineimage.jpg",
+ "image/jpeg",
+ BinaryData.fromString("test")
+ ).setContentId("inline_image");
+
+ EmailMessage message = new EmailMessage()
+ .setSenderAddress(SENDER_ADDRESS)
+ .setToRecipients(RECIPIENT_ADDRESS)
+ .setSubject("test subject")
+ .setBodyHtml("test message
")
+ .setAttachments(attachment);
+
+ StepVerifier.create(emailAsyncClient.beginSend(message).last())
+ .assertNext(response -> {
+ assertEquals(response.getValue().getStatus(), EmailSendStatus.SUCCEEDED);
+ })
+ .verifyComplete();
+ }
}
diff --git a/sdk/communication/azure-communication-email/src/test/java/com/azure/communication/email/EmailClientTests.java b/sdk/communication/azure-communication-email/src/test/java/com/azure/communication/email/EmailClientTests.java
index 590e474ab91b7..db383b54bfbc6 100644
--- a/sdk/communication/azure-communication-email/src/test/java/com/azure/communication/email/EmailClientTests.java
+++ b/sdk/communication/azure-communication-email/src/test/java/com/azure/communication/email/EmailClientTests.java
@@ -84,4 +84,28 @@ public void sendEmailWithAttachment(HttpClient httpClient) {
assertEquals(response.getValue().getStatus(), EmailSendStatus.SUCCEEDED);
}
+
+ @ParameterizedTest
+ @MethodSource("getTestParameters")
+ public void sendEmailWithInlineAttachment(HttpClient httpClient) {
+ emailClient = getEmailClient(httpClient);
+
+ EmailAttachment attachment = new EmailAttachment(
+ "inlineimage.jpg",
+ "image/jpeg",
+ BinaryData.fromString("test")
+ ).setContentId("inline_image");
+
+ EmailMessage message = new EmailMessage()
+ .setSenderAddress(SENDER_ADDRESS)
+ .setToRecipients(RECIPIENT_ADDRESS)
+ .setSubject("test subject")
+ .setBodyHtml("test message
")
+ .setAttachments(attachment);
+
+ SyncPoller poller = emailClient.beginSend(message);
+ PollResponse response = poller.waitForCompletion();
+
+ assertEquals(response.getValue().getStatus(), EmailSendStatus.SUCCEEDED);
+ }
}
diff --git a/sdk/communication/azure-communication-email/swagger/README.md b/sdk/communication/azure-communication-email/swagger/README.md
index 24c8f181323b9..81e6d0afffbc3 100644
--- a/sdk/communication/azure-communication-email/swagger/README.md
+++ b/sdk/communication/azure-communication-email/swagger/README.md
@@ -1,7 +1,7 @@
## Generate autorest code
```yaml
-require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/ac29c822ecd5f6054cd17c46839e7c04a1114c6d/specification/communication/data-plane/Email/readme.md
+require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/e64ad693df24b47d4009eece6663c8d95cf94be6/specification/communication/data-plane/Email/readme.md
output-folder: ../
license-header: MICROSOFT_MIT_SMALL
title: Azure Communication Email Service
@@ -22,7 +22,7 @@ required-fields-as-ctor-args: true
generate-client-as-impl: true
url-as-string: true
service-versions:
-- 2023-03-31
+- 2024-07-01-preview
polling:
default:
intermediate-type: EmailSendResult