Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you expose method to get domain name from email address #766

Closed
tovyhnal opened this issue Feb 13, 2022 · 4 comments
Closed

Can you expose method to get domain name from email address #766

tovyhnal opened this issue Feb 13, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@tovyhnal
Copy link

Can you please expose method, which would extract domain name from email address. Eg:
[email protected] would return contoso.com

@jstedfast jstedfast added the enhancement New feature or request label Feb 13, 2022
@jstedfast
Copy link
Owner

That's effectively just this:

int at = mailbox.Address.LastIndexOf ('@');
var domain = mailbox.Address.Substring (at + 1);

@tovyhnal
Copy link
Author

tovyhnal commented Feb 14, 2022

Not really, for this input this would not work: "Mr Valid" <[email protected]>

@jstedfast
Copy link
Owner

MailboxAddress.Address does not include the name. It only includes the [email protected]

@jstedfast
Copy link
Owner

jstedfast commented Feb 15, 2022

This is what you'd do:

var mailbox = MailboxAddress.Parse ("\"Mr Valid\" <[email protected]>");
int at = mailbox.Address.LastIndexOf ('@');
var domain = mailbox.Address.Substring (at + 1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants