Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Need blank line between each mail body part, How???

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need blank line between each mail body part, How???

    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


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Need blank line between each mail body part, How???

    Welcome to the forum
    Please see the Announcements page for the use of code tags

    What did you try? What happened?

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need blank line between each mail body part, How???

    I have try to insert System.getProperty("line.separator") as setText to the part but nothing happen. Also try to insert in System.getProperty("line.separator") prior to addMultipart and no result.

Similar Threads

  1. please any body help me
    By lanya in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 1st, 2013, 01:11 PM
  2. Blank screen on startup
    By CjStaal in forum Android Development
    Replies: 0
    Last Post: October 15th, 2012, 02:12 PM
  3. Blank JFrame
    By SACoder in forum AWT / Java Swing
    Replies: 2
    Last Post: August 30th, 2012, 12:25 PM
  4. Blank JFrame
    By SACoder in forum AWT / Java Swing
    Replies: 0
    Last Post: July 11th, 2012, 12:10 PM
  5. Replies: 10
    Last Post: September 16th, 2011, 08:49 PM