-
-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachment names are not always parsed properly from MimeMessage #175
Comments
I can get real file name by the code below: email.getAttachments().get(0).getDataSource().getName(); My original purpose is to get a mail from inbox, and then use it's attachment to create new mail to send, the file name not right. full code blow: @Test
public void forward() throws MessagingException {
Session session = ServerConfigUtils.getSession();
Store store = session.getStore("imap");
store.connect(Constants.imap_host, Constants.from, Constants.password);
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_WRITE);
Message message = folder.getMessage(2);
// get mail from inbox
Email oldEmail = EmailConverter.mimeMessageToEmail((MimeMessage) message);
// get use old mail content
Email newEmail = EmailBuilder.startingBlank()
.from("Rick", Constants.from)
.to("Ashley", Constants.email)
.withSubject("转发:this is subject")
// from old mail
.withEmbeddedImages(oldEmail.getEmbeddedImages())
.withAttachments(oldEmail.getAttachments())
.withHTMLText(oldEmail.getHTMLText())
.prependTextHTML("this is my own message")
.buildEmail();
Mailer mailer = MailerBuilder
.withTransportStrategy(TransportStrategy.SMTP)
.withSMTPServer(Constants.host, 25, Constants.from, Constants.password)
.buildMailer();
mailer.sendMail(newEmail);
} |
This seems like a bug to me. Looking into it now. I do have a junit test that checks this functionality (MailerTest.testParser()), so let me check if I'm missing something there. |
…e <> wrapping. Also, fixed how the tests deal with these names and made it more clear how the attachment name overrides affect conversion results
Fix released under 5.0.7. Please verify, @jkxyx205. |
The bug has been fixed, thank you very much for high efficient modification. @bbottema |
Repo maintainer's note: Summarizing, the issue is that resource names that are wrapped inside <..> are not read back properly, resulting in double extensions.
Hi Benny Bottema,
a.txt
a.txt.txt
which is not expect.When I trace source code,I found
How can i get the right file name 'a.txt'. Look forward to your relay, thank you.
The text was updated successfully, but these errors were encountered: