Jump to content

How I can controling sleep duration with UniScreenMask


LJDP
 Share

Recommended Posts

After trying the example UIMask not quite understand how it works.

In ISAPI mode, I need to activate a UniScreenMask after pressing a button while sending an email. I do not know the time the server need for sending email. How I can form lock while sending email and unlock when finish?

Link to comment
Share on other sites

thanks for the response.

I tried several ways to use UniScreenMask and have not found any satisfactory.

This is my last code to send an email. I need to lock the window while sent email and at the end show a menssage with the action result.

this is my code:

procedure TUsuCorreo.BCorreoClick(Sender: TObject);
var SMTP: TIdSMTP;
  Mensaje: TIdMessage;
  Adjunto: TIdAttachmentFile;
begin
 BCorreo.Visible := false;
 LErro.Caption := 'ENVIANDO MAIL';
 Lerro.Refresh;
 Resultado := '';
 with TIniFile.Create(FicIni) do begin
   try
     sHost := ReadString('RH','MAIL_HOST','');
     sPort := ReadString('RH','MAIL_PORT','');
     sUsuario := ReadString('RH','MAIL_USUARIO','');
     sClave := ReadString('RH','MAIL_CLAVE','');
     sFromNome := ReadString('RH','MAIL_FROMNOME','');
     sFromEmail := ReadString('RH','MAIL_FROMEMAIL','');
     sReplyTo := ReadString('RH','MAIL_REPLYTO','');
     sAdjunto  := '';
     sCopia := ReadString('RH','MAIL_COPIA','');
     sAsunto := 'Web, reenvio de clave de acceso de usuario';
     sMensaje  :=
       '<html><body>'+
       '<p>Solicitou Vde. o reenvio do constrasinal para acceder á web'+
       '<p>Os seus datos de acceso son:'+
       '<p>Usuario: <b>'+UniMainModule.QueryUsu.FieldByName('TER_DNI').AsString+'</b>'+
       '<p>Contrasinal: <b>'+UniMainModule.QueryUsu.FieldByName('EXPDIA_CLAVE').AsString+'</b>'+
       '<br><p>Trate estos datos con prudencia xa que dan acceso a información confidencial'+
       '</body></html>';
   except
     Resultado := 'Erro ó cargar parámetros';
   end;
 end;
 Resultado := '';
 SMTP := TIdSMTP.Create( nil );
 SMTP.Username := sUsuario;
 SMTP.Password := sClave;
 SMTP.Host := sHost;
 try
   SMTP.Port := strtoint(sPort);
 except
   SMTP.Port := 25;
 end;
 SMTP.AuthType := satDEFAULT;       
 Mensaje := TIdMessage.Create( nil );
 Mensaje.Clear;
 Mensaje.ReplyTo.EMailAddresses := sReplyTo;
 with TIdText.Create(Mensaje.MessageParts, nil) do begin
   Body.Text := sMensaje;
   ContentType := 'text/html';
 end;
 Mensaje.ContentType := 'multipart/alternative';
 Mensaje.From.Name := sFromNome;
 Mensaje.From.Address := sFromEmail;
 Mensaje.Subject := sAsunto;
 if trim(sCopia)<>'' then begin
   Mensaje.BccList.Add;
   Mensaje.BccList.Items[0].Address := sCopia;
 end;
 Mensaje.Recipients.Add;
 Mensaje.Recipients.Items[0].Address := sDestino;
 if sAdjunto <> '' then begin
    if FileExists( sAdjunto ) then
      Adjunto := TIdAttachmentFile.Create(Mensaje.MessageParts, sAdjunto);
 end else
    Adjunto := nil;
 try
    SMTP.Connect;
 except
   Resultado := 'Erro ó conectar co servidor';
 end;
 if SMTP.Connected then
 begin
    try
      SMTP.Send( Mensaje );
    except
      Resultado := 'Erro ó enviar a mensaxe';
    end;
    try
       SMTP.Disconnect;
    except
      Resultado := 'Erro ó desconectar do servidor';
    end;
 end;
 if Adjunto <> nil then
    FreeAndNil( Adjunto );
 FreeAndNil( Mensaje );
 FreeAndNil( SMTP );
 Resultado := 'Enviuse o contrasinal ó Email que tes no teu perfil de usuario.';
 LErro.Caption := Resultado;
 LErro.Refresh;
 Lerro.Repaint;
end;

And UniScreenMask:

 object Espera: TUniScreenMask
   AttachedControl = BCorreo
   Enabled = True
   DisplayMessage = 'Enviando eMail'
   Left = 218
   Top = 72
 end

How I do for Uniscreenmask display throughout the event?.

Thanks.

Link to comment
Share on other sites

Excuse my ignorance but I dont understand this:

Does above code wait until email is sent?

The mail has been sent when it reaches the end of the procedure:

how do you understand that email is sent?

This is the real code:

procedure TUsuCorreo.BCorreoClick(Sender: TObject);
var SMTP: TIdSMTP;
  Mensaje: TIdMessage;
  Adjunto: TIdAttachmentFile;
begin
 try
    SMTP.Connect;
 except
   MessageDlg('Erro ó conectar co servidor', mtWarning, []);
   Exit;
 end;
 if SMTP.Connected then begin
    try
      SMTP.Send( Mensaje );
    except
      MessageDlg('Erro ó enviar a mensaxe', mtWarning, []);
      Exit;
    end;
    try
       SMTP.Disconnect;
    except
      MessageDlg('Erro ó desconectar do servidor', mtWarning, []);
      Exit;
    end;
 end;
 if Adjunto <> nil then
FreeAndNil( Adjunto );
 FreeAndNil( Mensaje );
 FreeAndNil( SMTP );
 MessageDlg('Enviuse o contrasinal ó Email que tes no teu perfil de usuario.', mtWarning, []);
end;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...