0

I am using apache common email library to send email , as follow

// Create the attachment
   EmailAttachment attachment = new EmailAttachment();
   attachment.setPath("mypictures/john.jpg");
   attachment.setDisposition(EmailAttachment.ATTACHMENT);
   attachment.setDescription("Picture of John");
   attachment.setName("John");

// Create the email message
   MultiPartEmail email = new MultiPartEmail();
   email.setHostName("mail.myserver.com");
   email.addTo("jdoe@somewhere.org", "John Doe");
   email.setFrom("me@apache.org", "Me");
   email.setSubject("The picture");
   email.setMsg("Here is the picture you wanted");

// add the attachment
   email.attach(attachment);

// send the email
   email.send();

I want to show progress bar until attached the file and send..

How can we do?

centic
  • 15,565
  • 9
  • 68
  • 125
Shahid Ghafoor
  • 2,991
  • 17
  • 68
  • 123
  • which frontend? what have you tried? – oers Oct 12 '12 at 08:31
  • @oers from Jsp pages , I send parameters to servlet , where email send code is written, as above. When the code last line, email.send() execute, it take time according to the file size, that I have attached. I want to show progress bar in jsp. – Shahid Ghafoor Oct 12 '12 at 13:24

1 Answers1

0

I don't see any way you can have a callback from commons-email which let's you know how much of the data is already transformed, so unless you hack into apache commons email itself you won't get notified from the library itself.

The only other way I see to "emulate" this is to build in some knowledge about how long a transfer usually takes, i.e. how many bytes you usually transfer per second and use this for a progress dialog display. But naturally this may lead to inaccurate information in the progress bar if transfer speed varies a lot over time or the application is used with different network connection types.

centic
  • 15,565
  • 9
  • 68
  • 125