Mht mail with attachments

Im working with JavaMail and I need to send MHT mails and MHT created in Word with attachments.
The point is to send HTML mails with attachments.

Any help?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I'm unfamiliar with the package you're using. But refer to the documentation with it. Details should be specified there.

HTH :)
for emails to be sent make sure to send the content type to "text/html" a sample code will look like this:

  protected void sendMail( MailValueObject theMail  )
        mailSession = Session.getInstance(props, null);

        Message msg = new MimeMessage( mailSession );
//        msg.setFrom();
        msg.setFrom( new InternetAddress( theMail.getFromAddress() ) );
        msg.setRecipients( Message.RecipientType.TO,
                            InternetAddress.parse(theMail.getToAddress() , false ) );
        if( theMail.getCcAddress() != null)
                            InternetAddress.parse(theMail.getCcAddress(), false));
        if( theMail.getBccAddress() != null)
          msg.setRecipients( Message.RecipientType.BCC,
                                  InternetAddress.parse(theMail.getBccAddress() , false ) );
        msg.setSubject( theMail.getSubject() );

        msg.setContent( theMail.getBodyText(), "text/html");

        msg.setHeader("X-Mailer", mailer);
        msg.setSentDate( getCurrentTimeStamp() );


where theMail is a normal been with the its member fields represents the single mail fields

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You just need to send the mht file as an attachment. Example here:
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

mjuriAuthor Commented:
In this case when the email is open, the email body to show is HTML or simple text?
here's an example of sending an image attachment with a html mail:

import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class HtmlImageExample {
  public static void main (String args[]) throws Exception {
    String host = args[0];
    String from = args[1];
    String to = args[2];
    String file = args[3];

    // Get system properties
    Properties props = System.getProperties();

    // Setup mail server
    props.put("", host);

    // Get session
    Session session = Session.getDefaultInstance(props, null);

    // Create the message
    Message message = new MimeMessage(session);

    // Fill its headers
    message.setSubject("Embedded Image");
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));

    // Create your new message part
    BodyPart messageBodyPart = new MimeBodyPart();

    // Set the HTML content, be sure it references the attachment
    String htmlText = "<H1>Hello</H1>" +
      "<img src=\"cid:memememe\">";

    // Set the content of the body part
    messageBodyPart.setContent(htmlText, "text/html");

    // Create a related multi-part to combine the parts
    MimeMultipart multipart = new MimeMultipart("related");

    // Add body part to multipart

    // Create part for the image
    messageBodyPart = new MimeBodyPart();

    // Fetch the image and associate to part
    DataSource fds = new FileDataSource(file);
    messageBodyPart.setDataHandler(new DataHandler(fds));

    // Add a header to connect to the HTML

    // Add part to multi-part

    // Associate multi-part with message

    // Send message
In this case when the email is open, the email body to show is HTML or simple text?

You can choose whatever you want. What you can't do is to have the whole mht file automatically integrated *as* the body of the mail. You'd have to unpack it to do that
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.