locked
RFC 2822 support in System.Net.Mail.MailMessage RRS feed

  • Question

  • Does System.Net.Mail.MailMessage support complete RFC 2822 standard?

    In other terms, do SMTP emails sent using System.Net.Mail.MailMessage are RFC 2822 compliant? 

    Friday, November 27, 2020 3:55 PM

All replies

  • Hi ChKsh,

    Thank you for posting here.

    You can develop the email validation using Regex.

    For example.

    public static bool IsValidEmail(string email)
    {
        Regex rx = new Regex(
        @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z");
        return rx.IsMatch(email);
    }

    Here are two related references you can check.

    1. Validating an email address 
    2. Best Regular Expression for Email Validation in C#

    Hope it could be helpful.

    Best Regards,

    Xingyu Zhao


    Visual Basic and CLR forum will be migrating to a new home on Microsoft Q&A! (VB.NET and CLR) We invite you to post new questions in the new home on Microsoft Q&A ! For more information, please refer to the sticky post(VB.NET and CLR).

    Monday, November 30, 2020 7:55 AM