1

我正在使用 apache common email library发送电子邮件,如下

// 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();

我想显示进度条,直到附加文件并发送..

我们该怎么办?

4

1 回答 1

0

我看不出有任何方法可以从 commons-email 进行回调,它可以让您知道有多少数据已经转换,因此除非您侵入 apache commons 电子邮件本身,否则您不会从库本身收到通知。

我看到“模拟”的唯一另一种方法是建立一些关于传输通常需要多长时间的知识,即您通常每秒传输多少字节并将其用于进度对话框显示。但是如果传输速度随时间变化很大或者应用程序与不同的网络连接类型一起使用,这自然会导致进度条中的信息不准确。

于 2013-02-15T08:53:21.017 回答