...open the standard email client?

Author: Marcel Verbeek

Category: System

uses Registry;

procedure OpenMailClient;
const
  
cMailClient = '\SOFTWARE\Clients\Mail\';
var
  
reg: TRegistry;
  RegClientDefault: string;
begin
  
reg := TRegistry.Create;
  try
    with 
reg do
    begin
      
CloseKey;
      RootKey := HKEY_LOCAL_MACHINE;
      if OpenKeyReadOnly(cMailClient) then  RegClientDefault := reg.ReadString('');
      if OpenKeyReadOnly(cMailClient + RegClientDefault + '\shell\open\command') then
        
WinExec(PChar(ReadString('')), SW_SHOWNORMAL);
    end;
  finally
    
reg.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
OpenMailClient;
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base