@Ho, Keith D It sounds like you're experiencing a common issue where different email clients render HTML and CSS differently. This issue is likely with the CSS formatting and not Azure Communication Service. I would however like to make a few suggestions in hopes that it helps you.
Here are a few suggestions to help ensure your images display consistently across both Windows and Mac:
- Use inline CSS styles for your images. This can help ensure that the styles are applied consistently across different email clients.
- Explicitly set the width and height attributes in the HTML tag itself.
- Sometimes wrapping your image in a table can help maintain consistent rendering.
- Ensure that the image DPI (dots per inch) is set correctly. Sometimes high-DPI images can appear larger on certain screens.
- Use email testing tools like Litmus or Email on Acid to preview how your email will look across different email clients and devices.
Here is your sample with a few of these changes implemented to help you get started:
message = {
"senderAddress": "DoNotReply@abcdefghijk.azurecomm.net",
"recipients": {
"to": [{"address": recipient_email}]
},
"content": {
"subject": f"ServiceNow Incident {incident_id} Created",
"html": f"""
<html>
<body>
<div>Hi {name},</div>
<br>
<div>Your ticket has been submitted with the incident id <strong>{incident_id}</strong>.</div>
<br>
<div>Had a great time talking!</div>
<div>Your Virtual Assistant</div>
<table>
<tr>
<td>
<img src="cid:Hallie" alt="Hallie" style="display: block; margin-top: 20px; width: 300px; height: auto; max-width: 100%;">
</td>
</tr>
</table>
</body>
</html>"""
},
"attachments": [
{
"name": "Hallie",
"contentId": "Hallie",
"contentType": "image/png",
"contentInBase64": image_base64
}
]
}