My application sends out mail with attachment. Problem arises if the attached filename is more than 60 characters. Because in that scenario, the filename is automatically trimmed to 60 characters when the recipient sees the mail in outlook. When I printed the headers in my java code I can see that the filename (1234567890123456789012345678901234567890123456789012345678901234567890.txt
) has been split into multiple parameters, slicing at the 60th character.
Content-Type: text/plain; charset=us-ascii; ^M
name*0=123456789012345678901234567890123456789012345678901234567890; ^M
name*1=1234567890.txt^M
Content-Transfer-Encoding: 7bit^M
Content-Disposition: attachment; ^M
filename*0=123456789012345678901234567890123456789012345678901234567890; ^M
filename*1=1234567890.txt^M
Somehow Outlook picks up only filename*0
I came across a post (https://docs.oracle.com/javaee/6/api/javax/mail/internet/package-summary.html) that said setting this property to false mail.mime.foldtext will help, but to no avail. Any pointers on this will be of great help
My java code snippet
MimeAttachment attachment = attachments[i];
MimeBodyPart bodyPart = new MimeBodyPart();
bodyPart.setDataHandler(new DataHandler(new MimeAttachmentDataSource(attachment)));
bodyPart.setFileName(attachment.getFilename());
bodyPart.setDisposition(MimeBodyPart.ATTACHMENT);
much thanks