简体   繁体   English

带有Apache普通电子邮件的进度栏

[英]progress bar with apache common email

I am using apache common email library to send email , as follow 我正在使用apache 公共电子邮件库发送电子邮件,如下

// 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? 我们该怎么办?

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. 我看不到可以通过commons-email进行回调的任何方法,它可以让您知道已经转换了多少数据,因此,除非您侵入了Apache Commons电子邮件本身,否则不会从库本身收到通知。

The only other way I see to "emulate" this is to build in some knowledge about how long a transfer usually takes, ie 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. 但是,如果传输速度随时间变化很大,或者应用程序使用不同的网络连接类型,则很自然会导致进度栏中的信息不正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM