wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes Need blank line between each mail body part Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Need blank line between each mail body part" Watch "Need blank line between each mail body part" New topic
Author

Need blank line between each mail body part

marc nguyen
Greenhorn

Joined: Sep 06, 2013
Posts: 2
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
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

I don't understand, why do you want the blank line?


PM Me If You Want to get Urgent Help on Java Programming
marc nguyen
Greenhorn

Joined: Sep 06, 2013
Posts: 2
Not me but the client is requesting for it. That is why it made my life a nightmare.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need blank line between each mail body part
 
Similar Threads
How To Send Multiple Attachments In An Email
javamail
embed the jpg to the email (it's attached)
Email problem when sending attachments
Embedding image to the email sent through JavaMail