Get domain for email

In vb.net 2.0,

sThisURL = Request.Url.AbsoluteUri

gets for example
http://www.domainname.com/pathdir/pathname.aspx

What I need is:
domainname.com because I want to create an email address of

info@domainname.com

Thanks for your help.
wilcor14Asked:
Who is Participating?
 
vb_jonasConnect With a Mentor Commented:
dim strEmailAddress as string

strEmailAddress ="info@" & str.Substring(str.IndexOf(".") + 1)

:-)
0
 
PlatoConsultantCommented:
uri.Host property Gets the host component of this instance.

Dim baseUri As New Uri("http://www.contoso.com:8080/")
Dim myUri As New Uri(baseUri,"shownew.htm?date=today")
       
Console.WriteLine(myUri.Host)

this will write the www.contoso.com


0
 
vb_jonasCommented:
Variation of a theme:

Dim str As String
str = Request.Url.AbsoluteUri.Host
MsgBox(str.Substring(str.IndexOf(".") + 1))

Will give you

domainname.com

since .Host gives you www.domainname.com

and str.IndexOf(".") gives the position of the first dot

and str.Substring(str.indexof(".")+1)) gives you everything after the first dot
0
All Courses

From novice to tech pro — start learning today.