procedure TDataImpresion.EnvioCorreo(Sender: TObject);
Var
ArcAdjunto,NomArchivo:string;
Adjunto:TIdAttachmentFile;
begin
with SMTP do
begin
AuthType := satDefault;
Port := StrToInt(BioPuerto.Text);
Host := BioHost.Text;
Username := BioNomUsuario.Text;
Password := BioNomClave.Text;
UseTLS := utUseImplicitTLS;
IOHandler:=Socket;
end;
with Socket do
begin
DefaultPort:=0;
Host:=BioHost.Text;
Destination:=BioHost.Text+':'+BioPuerto.Text;
Port:=StrToInt(BioPuerto.Text);
SSLOptions.Method:=sslvSSLv3;
SSLOptions.Mode:=sslmUnassigned;
SSLOptions.VerifyDepth:=0;
end;
Mensaje.Clear;
with Mensaje do
begin
Recipients.Clear;
Recipients.Add;
Recipients[0].Name := 'EFREN AGUILAR';
Recipients[0].Address := BioPara.Text;
From.Name := Global.Cia.Nombre;
From.Address := BioNomUsuario.Text;
Subject := BioAsunto.Text;
Body.Clear;
Body.Text :=BioTexto.Lines.Text;
IsEncoded :=False;
ContentType := 'multipart/mixed';
MessageParts.Clear;
Priority := mpHighest;
end;
ArcAdjunto:=ArchivoAdjunto;
if (ArcAdjunto<>'') and (FileExists(ArcAdjunto)) then
begin
NomArchivo:=ExtractFileName(ArcAdjunto);
Adjunto:=TIdAttachmentFile.Create(Mensaje.MessageParts, ArcAdjunto);
Adjunto.ContentType:='application/pdf';
Adjunto. FileName:=NomArchivo;
Adjunto.ContentID:=NomArchivo;
Adjunto.DisplayName:=NomArchivo;
end
else
begin
Adjunto := nil;
end;
try
Smtp.Connect;
try
smtp.Send(Mensaje);
ShowMessage('El Correo Fue Enviado Satisfactoriamente...');
except
on E: Exception do ShowMessage(E.Message);
end;
finally
if smtp.Connected then
smtp.Disconnect;
if Adjunto <> nil then
FreeAndNil( Adjunto );
end;
end;