Board index » delphi » how to display progress bar while mail is being sent D7/indy10

how to display progress bar while mail is being sent D7/indy10


2005-05-03 08:22:19 PM
delphi248
I would like to display a progress bar while mail is being sent, to indicate
to the user that something is happenning after they've pressed the 'send
mail' button. Is the a way to do this? Here's my onclick event handler code:
procedure TForm4.btSendClick(Sender: TObject);
var
td:tdatetime;
begin
td:=now;
if(length(ledto.Text) <1)or (length(ledfrom.Text) <1) or
(length(ledsubject.Text) <1) then begin
playsound('stop.wav',0,SND_ASYNC);
showmessage('Please fill in ALL the fields.');
exit;
end
else
StatusMemo.Clear;
//setup SMTP
sen.Host :=host1 ;
sen.Port := 25;
sen.Password:=pw1;
//setup mail message
Mess2.From.Address:=ledFrom.Text;
Mess2.Recipients.EMailAddresses:=ledTo.Text;
Mess2.CCList.EMailAddresses:=ledCC.Text;
Mess2.Subject :=ledSubject.Text;
Mess2.Body.Text := Body.Lines.Text;
if FileExists(ledAttachment.Text) then
TIdAttachmentfile.Create(Mess2.MessageParts, ledAttachment.Text);
//send mail
try
try
sen.Connect;
sen.Send(mess2);
showmessage('Message successfully Sent at ' + datetimetostr(td) + ' to
' + ledto.Text +'!');
except on E:Exception do
showmessage(E.Message);
end;
finally
if Sen.Connected then
Sen.Disconnect;
end;
end;
Thanks
 
 

Re:how to display progress bar while mail is being sent D7/indy10

Quote
I would like to display a progress bar while mail is being sent,
Check the OnWork, OnWorkBegin and OnWorkEnd events of TidSMTP.
--
Goran Skledar
blog.goranskledar.com
 

Re:how to display progress bar while mail is being sent D7/indy10

Quote
>I would like to display a progress bar while mail is being sent,
Check the OnWork, OnWorkBegin and OnWorkEnd events of TidSMTP.
With the additional warning that messages are encoded on the fly using SMTP; the only way to know the total number of bytes to be transferred is to save the message to a file or stream prior to sending it.