Add error message if unable to generate img

This commit is contained in:
Gabriele C 2015-07-29 18:44:06 +02:00
parent f016d682c5
commit b8a2240982

View File

@ -82,14 +82,18 @@ public class SendMailSSL {
// Generate an image ? // Generate an image ?
File file = null; File file = null;
if (Settings.generateImage) { if (Settings.generateImage) {
ImageGenerator gen = new ImageGenerator(newPass); try {
file = new File(plugin.getDataFolder() + File.separator + auth.getNickname() + "_new_pass.jpg"); ImageGenerator gen = new ImageGenerator(newPass);
ImageIO.write(gen.generateImage(), "jpg", file); file = new File(plugin.getDataFolder() + File.separator + auth.getNickname() + "_new_pass.jpg");
messageBodyPart = new MimeBodyPart(); ImageIO.write(gen.generateImage(), "jpg", file);
DataSource source = new FileDataSource(file); messageBodyPart = new MimeBodyPart();
messageBodyPart.setDataHandler(new DataHandler(source)); DataSource source = new FileDataSource(file);
messageBodyPart.setFileName(auth.getNickname() + "_new_pass.jpg"); messageBodyPart.setDataHandler(new DataHandler(source));
multipart.addBodyPart(messageBodyPart); messageBodyPart.setFileName(auth.getNickname() + "_new_pass.jpg");
multipart.addBodyPart(messageBodyPart);
} catch (Exception e) {
ConsoleLogger.showError("Unable to send new password as image! Using normal text! Dest: " + mail);
}
} }
message.setContent(multipart); message.setContent(multipart);