About JavaMail sending large attachment problems!!! Online and so on.

Recently I wrote a mail client

Don't know this about accessories, hope the exhibitions, the following code posted to add an attachment.

(this annex have been uploaded to the server to a folder)

The test environment, locahost, upload time probably is about 10s, but why such a card to send?

//In front of ellipsis....
Multipart mainPart = new MimeMultipart(); 
// Create a HTML contains the contents of the MimeBodyPart   
BodyPart html = new MimeBodyPart();   
// Set the HTML content   
html.setContent(content, "text/html; charset=utf-8");
Circulation add attachments
for(TbAccessoryBase file:fileList){
	BodyPart attachmentPart= new MimeBodyPart();
	DataSource source = new FileDataSource(file.getFilePath());
	attachmentPart.setDataHandler(new DataHandler(source));
//Note: the following definition of the ENC object is used to deal with Chinese attachment name, otherwise the Chinese name is attached // display in the mailbox will be garbled, 
    sun.misc.BASE64Encoder enc = new sun.misc.BASE64Encoder();
    //The multipart object in message

Transport transport = sendMailSession.getTransport();
transport.connect(ServerConfig.SMTP_SERVER, auto.getUsername(), auto.getPassword());
//The time here to send probably card a few minutes (1.5G attachment)
transport.sendMessage(mailMessage, mailMessage.getAllRecipients());

This code can be successfully sent, but efficiency is not high, and great advice!!!!!!!!!!

Seeking guidance!!! For code!!!

Started by Jamie at November 13, 2016 - 3:55 PM

O God, seeking guidance!!

Posted by Jamie at November 25, 2016 - 4:35 PM