• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multipart emial error (creating .eml attachement which is resticted by email server)

Jo Adi
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am having problem sending a multipart email, I am getting following error in my mail box along with other server parameters

file is denied: $rfc822.eml

[MIME content for this item is stored in attachment $RFC822.eml. Parsing MIME content failed: Incorrect format in MIME data..]

The subject is populated with
Hello XYZ [Restricted Attachment]

Even though I am not attaching any thing for some reason the multipart email is considered as an attachment with .eml extension.

Code snippet for creating the multipart email

String emailSubject1 = messageResources.getMessage(request.getLocale(),
String emailContent = messageResources.getMessage(request.getLocale(),
"info.emailBody", options);

String emailTextPart1 = null;
String emailHtmlPart1 = null;
int emailType = 0;
emailType = EmailFormat.TYPE_PLAIN_TEXT;
emailTextPart1 = EmailFormat.format(request, messageResources, emailContent, emailType);
emailType = EmailFormat.TYPE_HTML_TEXT;
emailHtmlPart1 = EmailFormat.format(request, messageResources, emailContent, emailType);
Email.sendEmail(toEmail, emailSubject1, emailTextPart1, emailHtmlPart1);

sendEmail basically creates multipart
MimeMultipart mp = new MimeMultipart( "alternative" );
MimeBodyPart textPart = new MimeBodyPart();
MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setDataHandler(new DataHandler( emailHtmlContent,"text/html"));

Imports used

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;
import javax.activation.DataHandler;

I am not trying to send any attachments so is there a way I can avoid creating .eml file which is being filtered by the emailing system.
Ulf Dittmer
Posts: 42968
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

If you use HTML that'll be considered an attachment. Try sending the email with text only (many people don't like getting HTML emails anyway).
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic