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 8766491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:34:01+00:00 2026-06-13T16:34:01+00:00

i am sending the inline image with email with mime message. Here is the

  • 0

i am sending the inline image with email with mime message. Here is the brief code for the same. This is working fine. My
question is i am not setting the MimeMessage content-type as multipart/related (Also not setting
multipart subtype as related)still my code is working fine and iam able to get the inline image at expected postion.
Should i really care about setting the Content-Type as multipart/related when i am referring the image part with cid
or server takes care of that?

  MimeMessage   msg = new MimeMessage(mailSession);
  MimeMultipart mpart = new MimeMultipart();
  MimeBodyPart bp = new MimeBodyPart();
  bp.setText("plain text and here is html image refering image part <img src="cid:Unique-ContentId" />", CHARSET_UTF_8, MESSAGE_HTML_CONTENT_TYPE);
  // add message body
  mpart.addBodyPart(bp);

 // adding inline image  part
  MimeBodyPart bodyPart1 = new MimeBodyPart();
  bodyPart1.setFileName("inline image");
  file1 = new File("image1");
  DataSource source1 = new FileDataSource(file);
  bodyPart1.setDataHandler(new DataHandler(source));
  bodyPart1.setDisposition(MimeBodyPart.INLINE);
  bodyPart1.setHeader("Content-ID", "Unique-ContentId");
  bodyPart1.setHeader("Content-Type", "image/jpeg");
  mpart.addBodyPart(bodyPart1);

  // At last setting multipart In MimeMessage
  msg.setContent(mpart);

Just for information my email client can be outlook,lotusnotes,yahoo,gmail,thunderbird

  • 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-13T16:34:02+00:00Added an answer on June 13, 2026 at 4:34 pm

    That’s what we call “luck”. 🙂

    Apparently the email clients you’re using are being very generous in the way they interpret the message you’re sending. There’s nothing in the email specs that suggest they should interpret such messages in this way.

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

Sidebar

Related Questions

sending an email: From: <...> X-Mailer: SnowBoss Reply-To: <...> X-Priority: 3 (Normal) Message-ID: <248.20091210135259@snowman2010.com>
I'm sending inline styles formatted tables to email bodies for sending out reports. The
We are sending out Word documents via email (automated system, not by hand). The
When sending a message I can see this in my console: Sent mail to
Sending XML from C# Server and receiving it it in Android Java client This
Sending the same pointer into two different shared_ptr 's is bad, it causes double
sending mail along with embedded image using asp.net I have already used following but
Sending Email in Android using JavaMail API without using the default/built-in app I'm trying
I'm trying to process html email by rendering a template and layout inline, and
Sending a DataTable's content in an html email, what is the preferred way to

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.