This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

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

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

File-Report
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(),
"info.emailSubject");
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();
textPart.setText(emailTextContent);
mp.addBodyPart(textPart);
MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setDataHandler(new DataHandler( emailHtmlContent,"text/html"));
mp.addBodyPart(htmlPart);
msg.setContent(mp);
Transport.send(msg);

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
Rancher
Posts: 42972
73
  • 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
Boost this thread!