1. Home
  2. Computing & Technology
  3. Delphi Programming

Extracting the domain (host) name from an e-mail address

By Zarko Gajic, About.com

If you have an email as a string value and want to extract only the domain (host) name from it, like in: "delphi.guide@about.com" - domain name = "about.com", you can use the next function:

~~~~~~~~~~~~~~~~~~~~~~~~~
//extract doman name from an email address
function EmailDomain(const email: string):string;
var
   Pos_AT : integer;
begin
   Pos_AT := Pos('@', email) ;
   Result := Copy(email, Pos_AT + 1, Length(email) - Pos_AT)
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Installing the BDE (manually or using an install program)
« Setting up application wide hot key (keyboard short cut)

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2004 Delphi Tips
  7. Extracting the domain (host) name from an e-mail address

©2009 About.com, a part of The New York Times Company.

All rights reserved.