Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 29-06-2006
Avatar de marcoszorrilla
marcoszorrilla marcoszorrilla is offline
Capo
 
Registrado: may 2003
Ubicación: Cantabria - España
Posts: 11.221
Poder: 10
marcoszorrilla Va por buen camino
Enviar un email. Método elegante

Código Delphi [-]
Un Form, Un TMemo y un TButton.
Codigo de Carlos Conca (ClubDelphi)

uses ShellApi;

Const
  EOL = '%0D%0A';           //   end of line
  Signature = EOL + EOL + 'Saludos desde París' + EOL + 'Carlos Conca';

Var
  MailTo,
  MailSubject,
  MailCC,         //  Carbon Copy
  MailBCC,        //  Blind Carbon Copy
  MailBody: String;


procedure RunDefaultMailer;
var
  header,
  mail : String;
  ShellResult : integer;
begin
  if (MailTo ='') then begin  //  también funciona sin destinatario
     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);
  //SHOWDEFAULT);
  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;
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 11:08:50.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi