Ver Mensaje Individual
  #3  
Antiguo 02-05-2013
reevil reevil is offline
Miembro
 
Registrado: abr 2006
Posts: 179
Reputación: 19
reevil Va por buen camino
Después de unas horas batallando me di por vencido con las INDY y opte por Synapse.
Código Delphi [-]
uses
   SMTPSend, MIMEPart, MIMEMess;
procedure TForm.SendEmailClick(Sender: TObject); 
var   
  MIMEText: TStrings;   
  MIMEPart: TMimePart;   
  MIMEMessage: TMimeMess; 
begin   
  MIMEText := TStringList.Create;   
  MIMEText.Add('Hello,');   
  MIMEText.Add('here is the text of your e-mail message,');   
  MIMEText.Add('if you want the HTML format, use AddPartHTML');   
  MIMEText.Add('or e.g. AddPartHTMLFromFile if you have your');   
  MIMEText.Add('HTML message content in a file.');    
  MIMEMessage := TMimeMess.Create;    
  with MIMEMessage do   
  try     
    Header.Date := Now;     
    Header.From := 'sender@from.com';     
    Header.ToList.Clear;     
    Header.ToList.Add('recipient@to.com');     
    Header.CcList.Clear;     
    Header.Subject := 'E-mail subject';     
    Header.XMailer := 'My mail client name';      
    MIMEPart := AddPartMultipart('mixed', nil);      
    AddPartText(MIMEText, MIMEPart);     
    AddPartBinaryFromFile('c:\voucher.pdf', MIMEPart);      
    EncodeMessage;      
    if SendToRaw(Header.From,  // e-mail sender                  
                 Header.ToList.CommaText,   // comma delimited recipient list                  
                 'smtp.server.com',         // SMTP server                  
                 Lines,                     // MIME message data                  
                 'login',                   // server authentication                  
                 'password')                // server authentication     
    then       
      ShowMessage('E-mail has been successfuly sent ')     
    else       
      ShowMessage('E-mail sending failed ');   
  finally     
    Free;     
    MIMEText.Free;   
  end; 
end;

Añadiendo las librerías y con las modificaciones para adaptarlo a mis necesidades, va perfecto ese código.

Lo encontré aquí: http://stackoverflow.com/questions/6...lient-agnostic

Última edición por Casimiro Notevi fecha: 02-05-2013 a las 12:11:36.
Responder Con Cita