Exemple #1
0
        public void GetMessageStatus_InvalidMessageId()
        {
            EmailClient emailClient = CreateEmailClient();

            if (IsAsync)
            {
                Assert.ThrowsAsync <ArgumentException>(async() => await emailClient.GetSendStatusAsync(string.Empty));
                Assert.ThrowsAsync <ArgumentException>(async() => await emailClient.GetSendStatusAsync(null));
            }
            else
            {
                Assert.Throws <ArgumentException>(() => emailClient.GetSendStatus(string.Empty));
                Assert.Throws <ArgumentException>(() => emailClient.GetSendStatus(null));
            }
        }
Exemple #2
0
        public async Task GetSendStatusAsync()
        {
            EmailClient emailClient = CreateEmailClient();

            SendEmailResult response = await SendEmailAsync(emailClient);

            Assert.IsNotNull(response);
            Assert.IsFalse(string.IsNullOrWhiteSpace(response.MessageId));
            Console.WriteLine($"MessageId={response.MessageId}");

            SendStatusResult messageStatusResponse = await emailClient.GetSendStatusAsync(response.MessageId);

            Assert.IsNotNull(messageStatusResponse);
            Console.WriteLine(messageStatusResponse.Status);
        }
Exemple #3
0
        public async Task GetSendEmailStatusAsync()
        {
            EmailClient client = CreateEmailClient();

            // Create the email content
            var emailContent = new EmailContent("This is the subject");

            emailContent.PlainText = "This is the body";

            // Create the recipient list
            var emailRecipients = new EmailRecipients(
                new List <EmailAddress>
            {
                new EmailAddress(
                    //@@ email: "<recipient email address>"
                    //@@ displayName: "<recipient displayname>"
                    /*@@*/ email: TestEnvironment.ToEmailAddress,
                    /*@@*/ displayName: "Customer Name")
            });

            // Create the EmailMessage
            var emailMessage = new EmailMessage(
                //@@ sender: "<Send email address>" // The email address of the domain registered with the Communication Services resource
                /*@@*/ sender: TestEnvironment.AzureManagedFromEmailAddress,
                emailContent,
                emailRecipients);

            #region Snippet:Azure_Communication_Email_GetSendStatusAsync
            SendEmailResult sendResult = await client.SendAsync(emailMessage);

            SendStatusResult status = await client.GetSendStatusAsync(sendResult.MessageId);

            #endregion Snippet:Azure_Communication_Email_GetSendStatusAsync

            Assert.False(string.IsNullOrEmpty(sendResult.MessageId));
        }