Hello all,
I have been trying different method to insert new blank line between the mail boundary and bodypart without a positive result. Please help me
. Here is the output
1. There must be a space between the xml (base64 encoded) and the attachment boundary.
Example –
Original:
aWNlLnBkZi5wZGY8L0F0dGFjaG1lbnRGaWxlbmFtZT4NCjxBdH RhY2htZW50U3RhdHVzQ2Q+Y3Np
bzo1PC9BdHRhY2htZW50U3RhdHVzQ2Q+DQo8L0ZpbGVBdHRhY2 htZW50SW5mbz4NCjxjc2lvOlJl
bWFya3NJbmZvPjxSZW1hcmtUZXh0PnRoaXMgaXMgYSB0ZXN0PC 9SZW1hcmtUZXh0PjwvY3NpbzpS
ZW1hcmtzSW5mbz48L0FjdGl2aXR5Tm90ZVJzPg0KPC9Db21tb2 5TdmNScz4NCg==
------=_Part_7_1101808044.1378474555659
Content-Type: application/pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=test.pdf
Content-ID: test.pdf
Edited:
aWNlLnBkZi5wZGY8L0F0dGFjaG1lbnRGaWxlbmFtZT4NCjxBdH RhY2htZW50U3RhdHVzQ2Q+Y3Np
bzo1PC9BdHRhY2htZW50U3RhdHVzQ2Q+DQo8L0ZpbGVBdHRhY2 htZW50SW5mbz4NCjxjc2lvOlJl
bWFya3NJbmZvPjxSZW1hcmtUZXh0PnRoaXMgaXMgYSB0ZXN0PC 9SZW1hcmtUZXh0PjwvY3NpbzpS
ZW1hcmtzSW5mbz48L0FjdGl2aXR5Tm90ZVJzPg0KPC9Db21tb2 5TdmNScz4NCg==
------=_Part_7_1101808044.1378474555659
Content-Type: application/pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=test.pdf
Content-ID: test.pdf
My code is as follow:
Multipart multipart = new MimeMultipart("related");
FileDataSource fds = new FileDataSource(savePath+"edocs_transaction_request .xml");
BodyPart part2 = new MimeBodyPart();
part2.setText(System.getProperty("line.separator") );
part2.setDataHandler(new DataHandler(fds));
part2.setFileName(fds.getName());
part2.setHeader("Content-Transfer-Encoding","base64");
part2.setHeader("Content-Type", "text/xml; charset=\"UTF-8\"");
part2.setHeader("Content-ID","ACORD");
multipart.addBodyPart(part2);
BodyPart part3 = new MimeBodyPart();
part3.setText(System.getProperty("line.separator") + System.getProperty("line.separator"));
fds = new FileDataSource(savePath+fileName.substring(fileNam eIndex+1));
part3.setDataHandler(new DataHandler(fds));
part3.setFileName(fds.getName().toLowerCase());
part3.setHeader("Content-Type", "application/pdf");
part3.setHeader("Content-ID", fds.getName().toLowerCase());
multipart.addBodyPart(part3);
msg.setContent(multipart);
msg.saveChanges();
javax.mail.Transport.send(msg);
I hope Someone can help me..
Many thanks