Un Form, Un TMemo y un TButton.
Codigo de Carlos Conca (ClubDelphi)
uses ShellApi;
Const
EOL = '%0D%0A'; Signature = EOL + EOL + 'Saludos desde París' + EOL + 'Carlos Conca';
Var
MailTo,
MailSubject,
MailCC, MailBCC, MailBody: String;
procedure RunDefaultMailer;
var
header,
mail : String;
ShellResult : integer;
begin
if (MailTo ='') then begin ShowMessage('Falta el destinatario...');
Exit;
end;
header := 'mailto:' + MailTo;
if (MailSubject >'') then header := header + '?Subject=' + MailSubject;
if (MailCC >'') then header := header + '&cc=' + MailCC;
if (MailBCC >'') then header := header + '&bcc=' + MailBCC;
mail := header + '&body=' + MailBody + Signature;
ShellResult := ShellExecute(Application.mainform.Handle,'open',PChar(mail), nil, nil, SW_MAXIMIZE);
if (ShellResult <= 32) then ShowMessage('Error Num '+IntToStr(ShellResult)+' en ShellExecute.'+
#13+'Consulte la ayuda de Delphi.'+#13+'lenght(mail) =
'+IntToStr(length(mail)));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
n: Integer;
begin
MailTo := 'foro@clubdelphi.com';
MailSubject := 'Cómo enviar un mail';
MailCC := 'gon@idecnet.com';
MailBCC := 'Billy@Microsoft.com';
MailBody := '';
if (Memo1.Lines.Count > 1) then begin
MailBody := MailBody + Memo1.Lines[0];
for n := 1 to Memo1.Lines.Count - 1 do
MailBody := MailBody + EOL + Memo1.Lines[n];
end;
RunDefaultMailer;
end;