Ver Mensaje Individual
  #4  
Antiguo 15-02-2011
Avatar de pacopenin
pacopenin pacopenin is offline
Miembro
 
Registrado: sep 2010
Ubicación: Asturias
Posts: 382
Reputación: 14
pacopenin Va por buen camino
Hola.

Yo no uso Indy, sino synapse y el siguiente ejemplo a mi me funciona bien :

Código Delphi [-]
procedure MailSend(const sSmtpHost, sSmtpPort, sSmtpUser, sSmtpPasswd, sFrom, sTo, sFileName: AnsiString);
var
  smtp: TSMTPSend;
begin
  smtp := TSMTPSend.Create;
  try
    smtp.UserName := sSmtpUser;
    smtp.Password := sSmtpPasswd;
 
    smtp.TargetHost := sSmtpHost;
    smtp.TargetPort := sSmtpPort;
 
    smtp.AutoTLS := true;
 
    if not smtp.Login() then
      raise ESMTP.Create('SMTP ERROR: Login:' + smtp.EnhCodeString);
 
    if not smtp.MailFrom(sFrom, Length(sFrom)) then
      raise ESMTP.Create('SMTP ERROR: MailFrom:' + smtp.EnhCodeString);
    if not smtp.MailTo(sTo) then
      raise ESMTP.Create('SMTP ERROR: MailTo:' + smtp.EnhCodeString);
    if not smtp.MailData(msg_lines) then
      raise ESMTP.Create('SMTP ERROR: MailData:' + smtp.EnhCodeString);
 
    if not smtp.Logout() then
      raise ESMTP.Create('SMTP ERROR: Logout:' + smtp.EnhCodeString);
  finally
    smtp.Free;
  end;
end;
 
procedure TForm1.Button2Click(Sender: TObject);
begin
 MailSend('smtp.gmail.com', '587', 'cuenta@gmail.com', 'password', 'cuenta.from@gmail.com', 'cooreoTo@correor.com', 'test.txt');
//
end;


Saludos,
__________________
http://www.gestionportable.com
Responder Con Cita