【问题标题】:progress bar with apache common email带有apache常用电子邮件的进度条
【发布时间】:2012-09-27 02:37:04
【问题描述】:

我正在使用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();

我想在附加文件并发送之前显示进度条..

我们该怎么做?

【问题讨论】:

  • 哪个前端?你试过什么?
  • @oers 来自 Jsp pages ,我将参数发送到 servlet ,其中编写了电子邮件发送代码,如上。当代码最后一行 email.send() 执行时,根据我附加的文件大小,它需要一些时间。我想在jsp中显示进度条。

标签: java jsp email progress-bar apache-commons-email


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2015-09-13
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    • 1970-01-01
    • 2016-09-21
    • 2012-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多