我看到Azure.Communication.Email是预发布的,所以它可能不工作,但是下面的示例代码挂起了。你知道Azure.Communication.Email是否工作吗?
var connectionString = "endpoint=xxxx";
// Authenticate the client
EmailClient emailClient = new EmailClient(connectionString);
EmailContent emailContent = new EmailContent("Welcome to Azure Communication Service Email APIs.");
emailContent.PlainText = "This email message is sent from Azure Communication Service Email using .NET SDK.";
List<EmailAddress> emailAddresses = new List<EmailAddress> { new EmailAddress("hello@test.com") { DisplayName = "Test Person" } };
EmailRecipients emailRecipients = new EmailRecipients(emailAddresses);
EmailMessage emailMessage = new EmailMessage("donotreply@test.com", emailContent, emailRecipients);
try
{
SendEmailResult emailResult = emailClient.Send(emailMessage, CancellationToken.None);
}
catch (Exception ex) { Console.WriteLine(string.Format("Error: {0}", ex.Message)); }
Console.WriteLine("Done");
Console.Read();
1条答案
按热度按时间vq8itlhq1#
我遵循此MS-DOCS使用Azure通信服务发送电子邮件。
请确保Azure通信服务与域已连接。