About This Page
This page is part of the Azure documentation. It contains code examples and configuration instructions for working with Azure services.
Bias Analysis
Bias Types:
⚠️
windows_first
⚠️
missing_linux_example
⚠️
windows_tools
Summary:
The documentation page demonstrates a Windows bias by using a Windows-style file path (C:\Users\Documents\attachment.pdf) in the code example, without mentioning or providing a Linux/macOS equivalent. There are no examples or notes for Linux users regarding file paths or environment differences. The sample code and instructions assume a Windows environment, and there is no guidance for cross-platform usage.
Recommendations:
- Provide file path examples for both Windows (C:\Users\Documents\attachment.pdf) and Linux/macOS (/home/user/Documents/attachment.pdf) in the code sample or add a note about cross-platform file paths.
- Explicitly mention that the .NET SDK and the example code are cross-platform and can be run on Windows, Linux, and macOS.
- Add a section or note about running the sample on Linux/macOS, including any relevant differences (such as file permissions or path separators).
- Ensure that all examples and instructions are inclusive of non-Windows environments to improve accessibility for Linux users.
Create pull request
Flagged Code Snippets
// Create the email content
var emailContent = new EmailContent("Welcome to Azure Communication Service Email APIs.")
{
PlainText = "This email message is sent from Azure Communication Service Email.",
Html = "<html><body><h1>Quick send email test</h1><br/><h4>This email message is sent from Azure Communication Service Email.</h4><p>This mail was sent using .NET SDK!!</p></body></html>"
};
// Create the EmailMessage
var emailMessage = new EmailMessage(
senderAddress: "donotreply@xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.azurecomm.net" // The email address of the domain registered with the Communication Services resource
recipientAddress: "emailalias@contoso.com"
content: emailContent);
// Create the EmailAttachment
var filePath = "C:\Users\Documents\attachment.pdf";
byte[] bytes = File.ReadAllBytes(filePath);
var contentBinaryData = new BinaryData(bytes);
var emailAttachment = new EmailAttachment("attachment.pdf", MediaTypeNames.Application.Pdf, contentBinaryData);
emailMessage.Attachments.Add(emailAttachment);
try
{
EmailSendOperation emailSendOperation = emailClient.Send(WaitUntil.Completed, emailMessage);
Console.WriteLine($"Email Sent. Status = {emailSendOperation.Value.Status}");
/// Get the OperationId so that it can be used for tracking the message for troubleshooting
string operationId = emailSendOperation.Id;
Console.WriteLine($"Email operation id = {operationId}");
}
catch (RequestFailedException ex)
{
/// OperationID is contained in the exception message and can be used for troubleshooting purposes
Console.WriteLine($"Email send operation failed with error code: {ex.ErrorCode}, message: {ex.Message}");
}