S
Slattery_T
I'm trying to figure out how to send a multipart email, one text part
and equivalent HTML part. I suppose it should be
multipart/alternative. This is what I've done:
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(returnAddress, returnName));
msg.setRecipient(Message.RecipientType.TO,
newInternetAddress(rb.getTo()));
Multipart mp = new MimeMultipart("alternative");
// First part: plain text
MimeBodyPart mbp = new MimeBodyPart();
/* stripTags remove HTML tags from my text */
mbp.setText(stripTags(msgBody), "UTF-8", "plain");
mp.addBodyPart(mbp);
MimeBodyPart mbhtml = new MimeBodyPart();
mbhtml.setText(msgBody, "UTF8", "html");
mp.addBodyPart(mbhtml);
msg.setContent(mp);
Transport.send(msg);
And I get IO Exception, no content. I see a method in the javadoc for
MimeBodyPart: setText(text, charset, subtype), all three arguments
Strings. But the compiler says there is no such method.
So how the heck do I put content into this message?
and equivalent HTML part. I suppose it should be
multipart/alternative. This is what I've done:
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(returnAddress, returnName));
msg.setRecipient(Message.RecipientType.TO,
newInternetAddress(rb.getTo()));
Multipart mp = new MimeMultipart("alternative");
// First part: plain text
MimeBodyPart mbp = new MimeBodyPart();
/* stripTags remove HTML tags from my text */
mbp.setText(stripTags(msgBody), "UTF-8", "plain");
mp.addBodyPart(mbp);
MimeBodyPart mbhtml = new MimeBodyPart();
mbhtml.setText(msgBody, "UTF8", "html");
mp.addBodyPart(mbhtml);
msg.setContent(mp);
Transport.send(msg);
And I get IO Exception, no content. I see a method in the javadoc for
MimeBodyPart: setText(text, charset, subtype), all three arguments
Strings. But the compiler says there is no such method.
So how the heck do I put content into this message?