Ver Mensaje Individual
  #5  
Antiguo 17-12-2003
Descendents Descendents is offline
Miembro
 
Registrado: may 2003
Ubicación: Barcelona
Posts: 396
Reputación: 22
Descendents Va por buen camino
Yo uso delphi 7 y winxp, outlook 2000.

Si copias todo el código que te puesto y lo añades a un unit nuevo, pones un boton y un memo y lo pruebas, a mi me funciona

Código:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,shellapi;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
   procedure RunDefaultMailer;  
    { Public declarations }
  end;


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


var
  Form1: TForm1;
  filen,
  MailTo,
  MailSubject,
  MailCC,         //  Carbon Copy
  MailBCC,        //  Blind Carbon Copy
  MailBody: String;


implementation

{$R *.dfm}


procedure TForm1.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;
  if (filen > '') then header := header + '&attachment="' + filen+'"';
  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
  filen := 'c:\r.txt';
  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;


end.

Saludos

Última edición por Descendents fecha: 17-12-2003 a las 13:16:26.
Responder Con Cita