I'm trying to extract the domain name from an email address. For example if an email address is info@mydomain.com i want to extract 'mydomain' from the string.
I have some C# code which does this:
[Code]....
This works fine - except if a user has an email address which contains a dot '.' (e.g. fname.lname@mydomain.com) then it throws the following error:
Length cannot be less than zero.Parameter name: length
Line 29: int startIndex = strEmail.IndexOf("@");Line 30: int endIndex = strEmail.IndexOf(".") - startIndex;Line 31: string domain = strEmail.Substring(startIndex + 1, endIndex - 1);
The problem is the first '.' in the email address is causing it to calculate the string from the incorrect position.
Is there a way to retify this - or does anyone know of another solution to extract the domain name from an email address?
how do I write a regular expression to filter out email adresses in asp.net mvc? I would like in example to allow users registering email adresses only if coming from [URL] domain.
able to validate any email address based on the domain. For example, the system says anybody with a microsoft.com email address can create an account. Here is my code so far, it doesn't appear to work.
If Not Regex.IsMatch(tbEmailAddress.Text.Trim, "^([0-9a-zA-Z]([-.w]*[0-9a-zA-Z])*@" + mySetting.EmailDomain)
In my registration form, there is field to enter email-id of member, i want to restrict user, so that he would not able to enter gmail, yahoo, radiff.... emailids is this possible.., Only company email id eg: priyanka@juncturetech.net must be allowed?
I am building an email feature in my website (jobs site). By using this functionality, recruiters will be able to send emails to candidates. I want an option so that the user can also set 'From Address' and the email should be ANTI-SPAM compliant.
In addition to the process of regex syntax validation of Email Addresses entered by users, I'm trying to check if the entered email address is a real one and does exist?The best I could achieve is to "Ping" the host the email address is associated with. But there are some other terms in the industry like Handshaking with Email Server, etc.not necessarily with 100% confirmation accurary!
How me can validate a email textbox to take only valid email address if error occur it show the error message in this textbox or as a tooltip. because in the form there is no space to show error message.
here is sender email but i want there wasn't any email address.I mean i want when users click on button and send me an email there wasn't any email address in sender details.
I am getting destination ip address from packets, now i want to get domain name from ip addess. i have use whois, to get domain name, but it works only for few sites i.e google,microsoft. its not working for rediff or yahoo, Is there another way to get domain name from ip address?
I have a need to poll a mail server and then extract a photo that is either embedded or attached to the email message.The goal is to extract the photo and save it to a disk file. The desired functionality is much like emailing a photo from your phone to Twitter, Flickr, etc.
I have to automate a program where whenever I receive an email with header "Item Number change: Rice 2 lbs" and the message says "Price for item 10023456 has been changed to $2.99"
I would like to extract this kind of specific emails from my emails and then extract item number (100023456) and price (2.99) and store it into temporary table or session and use this information to change the value in the database. Instead of opening database manually and change the price.