How to get only email id from email address

image

Hi,

I got this output after reading email from email id. I need only email from whole email address. Please help me in this.

Thanks & Regards,
Mohd.

Hi @mohammed_zain
Are you reading this from a MailMessage object or is this a String value you’re getting from some other source?

  1. If you have access to the MailMessage object, which is the email item itself, then you can access MailMessage.From property to get the email address.
  2. If it’s a String value, then do this:
    emailOnly = emailString.Substring(emailString.IndexOf("<") + 1)
    This will give you the value skulkarni.....@naukri.com>
    Then remove it with Replace method.
    emailOnly = emailOnly.Replace(">", "")
    You can also do this in one method call i.e.
    emailOnly = emailString.Substring(emailString.IndexOf("<") + 1).Replace(">", "")
1 Like

Thanks a lot bro.

Happy Automation.
Mohd

2 Likes

Not using ‘Solution’ right, but you’re welcome! :smiley:

Cheers!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.