LJDP Posted January 17, 2012 Share Posted January 17, 2012 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 More sharing options...
Administrators Farshad Mohajeri Posted January 17, 2012 Administrators Share Posted January 17, 2012 ScreenMask will remain visible as long as server is busy. If you want to keep it visible remain in event until your task is fully finished. Link to comment Share on other sites More sharing options...
LJDP Posted January 18, 2012 Author Share Posted January 18, 2012 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 More sharing options...
LJDP Posted January 19, 2012 Author Share Posted January 19, 2012 can someone tell me I'm doing wrong? Please. Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted January 19, 2012 Administrators Share Posted January 19, 2012 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; Does above code wait until email is sent? i.e. how do you understand that email is sent? Link to comment Share on other sites More sharing options...
LJDP Posted January 19, 2012 Author Share Posted January 19, 2012 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 More sharing options...
Administrators Farshad Mohajeri Posted January 19, 2012 Administrators Share Posted January 19, 2012 So all you need is to attach ScreenMask to the Button which initiates mail sending. Link to comment Share on other sites More sharing options...
LJDP Posted January 19, 2012 Author Share Posted January 19, 2012 I've done. View dfm: object Espera: TUniScreenMask AttachedControl = BCorreo Enabled = True DisplayMessage = 'Enviando eMail' Left = 218 Top = 72 end Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted January 19, 2012 Administrators Share Posted January 19, 2012 So does mask display at all when you press the button? Link to comment Share on other sites More sharing options...
LJDP Posted January 19, 2012 Author Share Posted January 19, 2012 I had a bug in my code: sleep(0) Sorry for my mistake and thanks for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now