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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:54:03+00:00 2026-05-29T03:54:03+00:00

I have some Java code which sends out an email with code somewhat like

  • 0

I have some Java code which sends out an email with code somewhat like the following:

MimeBodyPart part = new MimeBodyPart();
part.setContent(htmlString, "text/html; charset=\"UTF-8\"");
part.setHeader("MIME-Version", "1.0");
part.setHeader("Content-Type", "text/html; charset=\"UTF-8\"");
part.setHeader("Importance", severityVal);

mimeMultiPart.addBodyPart(htmlPart);
mimeMessage.setContent(mimeMultiPart);

… and so on.

How can I encode the “part” MimeBodyPart in base64 for this outgoing email?

  • 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-05-29T03:54:04+00:00Added an answer on May 29, 2026 at 3:54 am

    From the docs:

    Q: Even though JavaMail does all the encoding and decoding for me, I need to manually control the encoding for some body parts.
    A: In the rare case that you need to control the encoding, there are several ways to override JavaMail’s default behavior. A simple approach is as follows. After creating the entire message, call msg.saveChanges() and then use something like mbp.setHeader("Content-Transfer-Encoding", "base64") to force base64 encoding for the given body part.

    Another approach is to subclass MimeBodyPart and override the updateHeaders method so that it first calls super.updateHeaders() and then sets the Content-Transfer-Encoding header as above.

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

Sidebar

Related Questions

I have some Java code which performs bitwise operations on a BitSet. I have
I have ported some LGPL code from Java to C#, which I plan to
I have to port some crypto code to visual c++ from java which (visual
I have some Java code that is throwing out of memory exceptions after running
I have encountered some java script code which I believe is malicious but most
I have some code which uses java.awt.Color. I want to translate my Java Code
I have some Java code that uses curly braces in two ways // Curly
I have some Java code that connects to an Oracle database using DriverManager.getConnection(). It
Let's say I have some Java code: public class SomeClass { static { private
We have a system that has some Bash scripts running besides Java code. Since

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.