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

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

By , About.com Guide

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)

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. 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.