Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:22:50+00:00 2026-06-14T23:22:50+00:00

How can I set start attribute in the content-type for mime multipart/related message? To

  • 0

How can I set start attribute in the content-type for mime multipart/related message?
To be more precise, I want to know how I can set the start attribute for the root attachment in the below example taken from https://www.rfc-editor.org/rfc/rfc6362:

--OUTER-BOUNDARY
Content-type: multipart/related; boundary="INNER-BOUNDARY";
   start="<root.attachment>"; type="application/xml"

--INNER-BOUNDARY
Content-type: application/xml
Content-ID: <root.attachment>

[XML DOCUMENT]

--INNER-BOUNDARY
Content-type: application/pdf
Content-ID: <2nd.attachment>

[PDF DOCUMENT]

--INNER-BOUNDARY--

--OUTER-BOUNDARY

I am not able to find it in the javax.mail api. Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:22:52+00:00Added an answer on June 14, 2026 at 11:22 pm

    I’ve been struggling with that recently, the code below is the best I could come up with (actually nothing else worked for me):

        public class MultipartGenerator {
    
          //Let's assume the static members below 
          //hold our message parts content 
          //an the instances of arrays of byte
    
          private static final byte [] ROOT_BYTES = new byte[]{/* ... bytes ... */};
    
          private static final byte [] ATTCH_1_BYTES = new byte[]{/* ... bytes ... */};
    
          private static final byte [] ATTCH_2_BYTES = new byte[]{/* ... bytes ... */};
    
          /**
           * Generate multipart with headers
           *
           * @return javax.mail.Multipart instance
           */
           public static Multipart generateMultipart() {
    
             //This is our root MimeBodyPart, 
             //content-id equals 'rootcid'
             //content-type equals 'roottype/rootsubtype'
    
             InternetHeaders ih0 = new InternetHeaders();
             ih0.addHeader("Content-Type", "roottype/rootsubtype");
             ih0.addHeader("Content-Transfer-Encoding", "binary");
             ih0.addHeader("Content-ID", "rootcid");
             MimeBodyPart rootBodyPart = new MimeBodyPart(ih0, ROOT_BYTES);
    
             //This is a body part wrapping first message attachment
             InternetHeaders ih1 = new InternetHeaders();
             ih1.addHeader("Content-Type", "text/plain; name=attachment1.txt");
             ih1.addHeader("Content-Transfer-Encoding", "binary");
             ih1.addHeader("Content-Location", "attachment1.txt");
             ih1.addHeader("Content-ID", "a00");
             MimeBodyPart attch1BodyPart = new MimeBodyPart(ih1, ATTCH_1_BYTES);
    
             //This is a body part wrapping second message attachment
             InternetHeaders ih2 = new InternetHeaders();
             ih2.addHeader("Content-Type", "text/plain; name=attachment2.txt");
             ih2.addHeader("Content-Transfer-Encoding", "binary");
             ih2.addHeader("Content-Location", "attachment2.txt");
             ih2.addHeader("Content-ID", "a01");        
             MimeBodyPart attch2BodyPart = new MimeBodyPart(ih2, ATTCH_2_BYTES);
    
             //This is our desired multipart, this is where things turn a bit dirty
             //No success with setting the parameters in a different way
    
             Multipart multipart = new MimeMultipart("related;start=\"<rootcid>\";type=\"roottype/rootsubtype\"");
    
             multipart.addBodyPart(rootBodyPart,0);
             multipart.addBodyPart(attch1BodyPart);
             multipart.addBodyPart(attch2BodyPart);
    
             return multipart;
           }
        }
    

    There’s probably a better way to handle this task, however I am not able to find one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I set a Microsoft SQL field as identity but to START with
The documentation says: $ play start Note: the HTTP port can be set by
I've been trying to get django set up so I can start learning it.
Before I start using CORBA I want to know something. It would seem intuitive
I can set the width and height of my canvas by setting the width
I can set the relationship between View Model and view through following DataContext syntax:
You can set the Vim color scheme by issuing :colorscheme SCHEME_NAME but, oddly enough,
I can set the event on the calendar on my device by using this
How can I can set a global variable for the username of the logged-in
In Photoshop you can set a layer's blending mode to be Hue. If that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.