Get email suffix (.net, .org, etc...) from email using Regular Expressions

Does anyone have a code snippet that could do this in VB.NET?

I want it to return .net if given bob@microsoft.net
Thanks,
ScAndal
.NET Web Based CRM http://www.kineticcrm.com
.NET Consulting http://www.kineticmedia.net
0
ScAndal
10/1/2004 4:03:40 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

2 Replies
1581 Views

Similar Articles

[PageSpeed] 37
Get it on Google Play
Get it on Apple App Store

Hm.  Well, I can get you started, but it won't handle sub-domain e-mails.  To make this example easier for me to think about, this regex will look for: someword@someword.some.more.words   (Why ".some.more.words"?  Because of international country extensions)  And it will save the ".some.more.words" part in the Groups property of the Match in index value 1.  (The index value 0 contains the full match.)  Again, this is a very simplistic example you will need to do more work on it.  Also, I am a C/C++/C# type of person and don't know VB.NET but I'll try to show it to you in VB.NET.


' Your e-mail address is in inputString
Dim r as Regex
Dim m as Match
r = New Regex("\w+@\w+((\.\w+)+)")
m = r.Match(inputString)
While m.Success
' The extension is saved in m.Groups(1).Value
' Do something with it here like this
Response.Write(m.Groups(1).Value)
m = m.NextMatch()
End While

As I said before, if you setup a mail server on dev.domain.co.uk and had an e-mail address of joeuser@dev.domain.co.uk, it'll end up returning .domain.co.uk. You will need to fix this, if you care about it.
As for the While loop, in case your input string has multiple e-mail addresses in it, it'll loop through them all. If you just want the first one, then you can get rid of the loop and the NextMatch thing.
0
Yuniest
10/1/2004 10:57:08 PM
Depending on how important it is, you could just as well use string manipulation:


Dim mail As String = "info@sonnenburg.se"
Dim topDomain As String = mail.Substring(mail.LastIndexOf("."))

This will return the top domain. However if you need e.g 'co.uk' this will not do.
Regards

Andre Colbiornsen
---------------------------------
Seventh Day
Råbygatan 1A,
SE-223 61 Lund
Sweden
Mob.: +46-(0)708-97 78 79
Mail: info@seventhday.se
--------------------------------
0
adec
10/2/2004 1:28:28 AM
Reply:

Similar Artilces:

using relay-host.secureserver.net & getting email on gmail and yahoo account but not getting it on my godaddy account
using smtp server address as relay-host.secureserver.net getting email on gmail and yahoo account but not getting it on my godaddy account. Please help me out, ...

getting email account of a particular user of outlook express in to .NET application..
Hi,  I want to retrieve the  a particular user email account of outlook express in to my .net application.Please help me. Hi, Based on my experience, if you develop a windows application, I suggest to use "Linq" to get the particular user accounts. Please refer to the following code. .cs file import the namespace using Microsoft.Office.Interop.Outlook;            _Application outlook = new Microsoft.Office.Interop.Outlook.Application();           &nb...

I've not be able to use my Firefox email lately because of a required password to get into it, which I do not have. So, I have had to go to Yahoo to get an email program. Is there a way to recover
Name: Billl Brewster Email: billb7824atcharterdotnet Product: Firefox Summary: I've not be able to use my Firefox email lately because of a required password to get into it, which I do not have. So, I have had to go to Yahoo to get an email program. Is there a way to recover whatever password got registered to my Firefox account? Comments: Thank you. See note in summary. Bill Brewster billb7824@charter.net Browser Details: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC ...

Two things,Why do I keep getting emails that I don't want. can't get rid of them? Why can't I get my email when I am out of town? Or can I?
Name: Ed Leech Email: ELCraftatzoominternetdotnet Product: Thunderbird Summary: Two things,Why do I keep getting emails that I don't want. can't get rid of them? Why can't I get my email when I am out of town? Or can I? Comments: I am getting frusted with all the emails coming in that I do not want, I am using the tools to get thme out but they keep coming. They just use different names or whatever. I have been thinking of just switching to something else but my business intrusts know this email and it is tooo confusing to change. Every time I go out of town on bu...

How to get new web app to use .NET 2.0 on Win2K server using .NET 1.1 as default framework?
I have .net framework1.1 and 2.0 on our server running win2K. i have existing applications that uses asp.net 1.1, i also have a new app that use ASP.net 2.0.  how can i set my new .NET 2.0 app to point to asp.net 2.0 without messing up my existing .NET 1.1 apps? To specify the ASP .Net version fro a web application, do the followingIn IIS Manager select the web application -> Properties -> ASP.Net TabSelect  ASP.Net version you want to use for the applicationRegards,PrashantDont forget to click "Mark as Answer" on the post that helped you. But I am running Win2K...

how to get the correct email format when sending email using sqldatareader
I'm getting the email address from an excel sheet.But i need to send the email to multiple peopleWhen printing the below i geta@a.com;b@b.com;; But i want a@a.com;b@b.com; i don't need the extra semicolon Thanks code below------ while (oledr.Read()) { smail = oledr[0].ToString() + ";" + "<br>";   //smail += oledr[0].ToString() & ";"; //mail.To.Add(smail); //this.Label1.Text = smail; Response.Write(smail); }   If oledr[0].ToString() contains only one email address (and not a few), then you can do it this way:while (oled...

Get email address from DB and send email using VB
OK every time I figure something out on my own, there's 10 more things I can't seem to figure out. I feel like a VB moron. Ha. Anyway. Here's what I need to do...1. Retrieve the email addresses from my database table of people whose memberships to my organization has expired in the past month.2. Somehow plug those email addresses into a code to send them a prewritten, preformatted email.I have found an article on how to send an email using VB coding. I just don't know how I would send one email to every person whose membership has expired in the past month. Ideally, I'd like to be able to lo...

How to get the CreateUserWizard to email using the DisplayName instead of From email address?
Hi,I'm trying to work out how to get the CreateUserWizard to email using the DisplayName (or equivalent) so that the recipient sees a name (e.g. Ben Miller) instead of an email address in the From field of their email client.  In my CreateUserWizard control I have tried putting a name (e.g Ben Miller) in like this:    <asp:CreateUserWizard...>    <MailDefinition BodyFileName="~/BodyFile.txt"            Subject="Welcome new User" From="user@domain.com, Ben Miller&quo...

used a c#.net to vb.net converter and am now getting a syntax error.
ok I used a cool utility at http://www.kamalpatel.net/ConvertCSharp2VB.aspx to convert some c#.net to vb.net and it spit out a bunch of code which almost works but I am getting a syntax error on this line Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) I tried it that way and also like Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) but either way gave the same error Compiler Error Message: BC30035: Syntax error. Source Error: Line 26: Line ...

System.Net.Mail
Hi and thanks for your help!! I have a window that pops up to send an email to a person using the following javascript: <script type="text/javascript"> //<![CDATA[function OnClientCommandExecuting(editor, args) {var commandName = args.get_commandName(); var strEmail = document.getElementById("PersonsEmail").value;if (args.get_commandName() == "SendEmail") { var oWnd = radopen("sendemail.aspx?email=" + strEmail, "rwEmail"); oWnd.center();args.set_cancel(true); } }   //]]> </script>   On the email ...

How to retrieve email from email account like anil@abc.com using vb.net
Hello to All, This is my first post. I am facing a problem in vb/asp .net that is we can send emails from asp/vb .net pages but we can't store mails that we are getting on email account like anil@abc.com  that is already happend in outlook. In short i want to develop this outlook facility. I want to store that emails on my local MSSQL Database. I want some concept sharing in this topic to solve this problem. Thanks in advance.   Regards, Anil http://www.webmultimediadesigner.com/ Hello, What storage medium are the e-mails stored in? If it is an exchange server, yo...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Keep getting..."Unable to get project file from server",when using vs.net
When trying to open any existing asp.net project in Visual Studio it keeps giving me the message above. It is also throwing an error when I create the project in the first place, it happens when a dos window is opened, the text in the dos window is running "Common Language Runtime Minidump Utility version 1.0.3705.0" and then VS craps out says there was an error and shuts down. I've re-installed the .net components and framework with no avail, and FrontPage extensions etc.. are all installed. I'm running XP professional and have installed IIS 5.1. This is driving me fec...

how to get start with .NET
the net help people installed  to my desktop 1-microsoft visual studio .NET enterprise developer 2003 2-microsoft .NET framework 1.1 what else do i need ...???  and how can i try with some simple code in VS.Net and run it to see wat happen...????? please help If you want to develope web applications, then you'll also need IIS on your PC.  That'll require XP-Professional or Windows 2000/2003, but XP-Home edition won't allow IIS installation. As for how to get started, you can search the web for some tutorials or buy a good book on VS.  The topic is way too vast to...

Web resources about - Get email suffix (.net, .org, etc...) from email using Regular Expressions - asp.net.getting-started

Closed-form expression - Wikipedia, the free encyclopedia
In mathematics , an expression is said to be a closed-form expression if it can be expressed analytically in terms of a finite number of certain ...

Fighting abuse to protect freedom of expression
We believe that protection from abuse and harassment is a vital part of empowering people to freely express themselves on Twitter. Today, as ...

Campus no longer safe place for freedom of expression says free speech advocate
A group representing free speech in Canada says universities are no longer safe places for free expression, instead shying away from being forums ...

Apple acquires ‘Emotient’ facial expression & emotion detection technology
The Wall Street Journal reports Apple has confirmed it has made an acquisition of artificial intelligence startup Emotient . The cloud-based ...

Duke Student Columnist: America’s First Amendment ‘Obsession’ Is ‘Expression Of White Supremacy’
Duke Student Columnist: America’s First Amendment ‘Obsession’ Is ‘Expression Of White Supremacy’

Disney's FaceDirector changes facial expressions in movies
The new tool out of Disney Research's labs could turn an ing&eacute;nue's semi-decent attempt into a finely nuanced performance. This software ...

Leonardo DiCaprio Reacts to Lady Gaga's Golden Globes Win See His Hilarious Expression!
Leonardo DiCaprio Reacts to Lady Gaga's Golden Globes Win See His Hilarious Expression!

Turkey's YouTube Ban Violated Freedom Of Expression, European Court Rules
A YouTube ban in Turkey that lasted two years has now been ruled a violation of the European Convention on Human Rights. Back in 2008, a Turkish ...

Redbubble, A Profitable Channel For Artistic Expression
There is a growing movement of people who never want to follow a trend. Instead they embrace their own creative self-expression and are just ...

Apple Acquires AI Firm Emotient, Their Tech Can Read Emotion In Facial Expressions
Apple Inc. seems to recognize the fact that studying facial expressions is a very big topic of interest for many technology companies. Which ...

Resources last updated: 1/21/2016 6:24:39 PM