简体   繁体   中英

ASP.NET Identity email fields - possible to add multiple emails in one field?

I have created an ASP.NET Web application using razor pages (not controllers) and this uses the Individual accounts from Identity.

The whole purpose of my site is that an admin logs in and uploads a document, they then press a button that sends an email to the receipting user to say they have a document to view.

I was wondering with microsoft identity, is there a possibility to use multiple emails? For example, putting a semi-colon between emails so that when the email is sent, it goes to multiple people.

注册新用户

The code im using behind the button to send the email is as follows:

using (var smtp = new System.Net.Mail.SmtpClient("ip address here"))
                                    {

                                        var emailMessage = new MailMessage();
                                        emailMessage.From = new MailAddress("email@gmail.com");
                                        emailMessage.To.Add(email);
                                        emailMessage.Subject = "New Document Avaialable!";
                                        emailMessage.Body = "You have a new purchase order available to view on the Portal!";

                                        await smtp.SendMailAsync(emailMessage);
                                    }

Fix as follows:

In the register.cshtml, there is an InputModel class that looks something along the lines of:

public class InputModel
        {
            [Required]
            [DataType(DataType.Text)]
            [Display(Name = "User Name")]
            public string UserName { get; set; }

            [Required]
            [EmailAddress]
            [Display(Name = "Email")]
            public string Email { get; set; }
}

First of all, I removed the [EmailAddress] from above the email.

Then instead of a semi-colon in the email text box, i put a comma between each email address and it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM