Ver Mensaje Individual
  #9  
Antiguo 03-01-2023
IVAND IVAND is offline
Miembro
 
Registrado: may 2003
Ubicación: ECUADOR
Posts: 523
Reputación: 21
IVAND Va por buen camino
Gracias por responder , si con la misma forma , uso delphi 2009 y los indy que vienen por defecto , uso el mismo codigo en delphi 11 y funciona sin problemas , parece que algo me falta en delphi 2009
Código Delphi [-]
procedure TForm1.Button2Click(Sender: TObject);
var smtp:TIdSMTP;
  mail:TIdMessage;
  Attachmentfile: TIdAttachmentFile;
begin
    smtp := TIdSMTP.Create(Self);
      Mail := TIdMessage.Create(Self);
      with smtp do
      begin

        Port:=465;
        Host:= 'smtp.gmail.com';
        Username:='comcasanova2018sa@gmail.com';
        Password:='hyzvtyccwttttt';  // 
        IOHandler:=SSLIOHandler;
        UseTLS := utUseExplicitTLS;
        AuthType:=satDefault ;
      end;

      SSLIOHandler.Port:= 465;
      SSLIOHandler.Host:= 'smtp.gmail.com';
      SSLIOHandler.Destination:='smtp.gmail.com:' + IntToStr(SSLIOHandler.Port);

      with mail do
      begin
        Recipients.Add;
        Recipients[0].Name   :='SitiSystems';
        Recipients.EmailAddresses:='ivand2011@gmail.com';
        From.Name            :='Integral ERP';
        From.Address         :='comcasanova2018sa@gmail.com';
        Subject              :='Se ha enviado un documento electronico';
        Body.Text:='Prueba de correo..revise adjunto'; // Es el texto del mensaje
        //ContentType := 'text / plain';
        CharSet      := 'utf-8';
        Encoding     := meMIME;
        Priority     := mpNormal;
        ContentType := 'multipart/mixed';
      end;
      Attachmentfile:=TIdAttachmentFile.Create(mail.MessageParts,'C:\Embajada\Ruc.pdf');
   //   Attachmentfile.FileName:='C:\Embajada\Ruc.pdf';
   //   Attachmentfile.ContentType := 'application/octet-stream';
   //   Attachmentfile.ContentID:='C:\Embajada\Ruc.pdf';
  //    Attachmentfile.DisplayName:='C:\Embajada\Ruc.pdf';
      try
        smtp.Connect;
      except
        ShowMessage('Ocurred an Error, The Message was not Sent');
      end;
        Screen.Cursor:=CrDefault;

      try
        smtp.Send(mail);
      except
      //on E: Exception do
        ShowMessage('The Message was not Sent');
      end;

      if smtp.Connected then
        smtp.Disconnect;
      mail.Free;
      smtp.Free;
end;

en uno funciona bien en otro no , que puede estar pasando , esperando sus consejos 
en 2009 envia el correo perfecto pero adjunta el archivo como noname y en delphi 11
__________________
IVAND
Responder Con Cita