Mega Code Archive

 
Categories / Delphi / Examples
 

Send E mail (default client) with subject and text

Title: Send E-mail (default client) with subject and text Question: How can I send an E-mail with subject and text? Answer: { Author: Cosmin Prlitu E-mail: cosmin.pirlitu@mail.com The following code opens the default e-mail client (i.e Outlook Express) with a specified e-mail, subject and text. } uses ShellAPI; { ...code...} procedure SendMail(Address, Subject, Text: string); var H: HWND; begin H:=Application.Handle; ShellExecute(H,'open',PChar('mailto:'+Address+'?subject='+Subject+ '&body='+Text),nil,nil,SW_SHOW); end; { example of use } procedure TMainForm.EmailButtonClick(Sender: TObject); begin SendMail('cosmin.pirlitu@mail.com','Delphi3000 Article','Hello Cosmin!'); end;