Parse plain email address into 2 parts

Use the MailAddress class

MailAddress addr = new MailAddress("hello@site.example");
string username = addr.User;
string domain = addr.Host;

This method has the benefit of also parsing situations like this (and others you may not be expecting):

MailAddress addr = new MailAddress("\"Mr. Hello\" <hello@site.example>");
string username = addr.User;
string host = addr.Host;

In both cases above:

Debug.Assert(username.Equals("hello"));
Debug.Assert(host.Equals("site.example"));

At the top of your file with the rest of your using directives add:

using System.Net.Mail;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)