Hallo Leute!
Ich habe folgendes Problem:
Ich möchte gerne eine Mail mit einem gezippten Attachment versenden, über mail.gmx.net
Ich bekomme aber immer die Fehlermeldung:
IOException while sending message;
nested Exception is: javax.activation.UnsupportedDataTypeException: no Object DCH for MIME type multipart/mixed
die Sende-Routine sieht so aus:
Bitte um Hilfe[/code]
Ich habe folgendes Problem:
Ich möchte gerne eine Mail mit einem gezippten Attachment versenden, über mail.gmx.net
Ich bekomme aber immer die Fehlermeldung:
IOException while sending message;
nested Exception is: javax.activation.UnsupportedDataTypeException: no Object DCH for MIME type multipart/mixed
die Sende-Routine sieht so aus:
Code:
public static void sendWithAuthenticatorAndAttachement (String userName, String password, String to, String from, String host, String betreff, String mailText, File attachFolder) throws Exception {
// Get system properties
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
// Setup authentication, get session
Authenticator auth = new MyAuthenticator(userName, password);
Session session = Session.getDefaultInstance(props, auth);
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject(betreff);
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(mailText);
//Create Multipart
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
//Attachment
messageBodyPart = new MimeBodyPart();
/*/
MIME Types
txt - text/plain
html - text/html
xml - text/xml
pdf - application/pdf
zip - application/x-zip-compressed
jpeg - image/jpeg
gif - image/gif
//*/
messageBodyPart.setDataHandler(new DataHandler(new FileDataSource(data),"application/x-zip-compressed"));
//data ist eine temporäre Datei die gezippt vorhanden ist. Ist als Datentyp java.io.File im Speicher.
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
// Send message
Transport transport = session.getTransport("smtp");
transport.connect(host, userName, password);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
Bitte um Hilfe[/code]