Properties props = System.getProperties(); props.setProperty("mail.store.protocol", "imaps"); try { Session session = Session.getDefaultInstance(props, null); javax.mail.Store store = session.getStore("imaps"); store.connect("imap.gmail.com", "<username>@gmail.com", "<password>"); javax.mail.Folder[] folders = store.getDefaultFolder().list("*"); for (javax.mail.Folder folder : folders) { if ((folder.getType() & javax.mail.Folder.HOLDS_MESSAGES) != 0) { System.out.println(folder.getFullName() + ": " + folder.getMessageCount()); } } } catch (MessagingException e) { e.printStackTrace(); }
public void sendMail(String email) { Map<String, Object> map = new HashMap<String, Object>(); map.put("email", email); try { String text = getTextByTemplate(template, map); send(email, text); } catch (IOException | TemplateException e) { e.printStackTrace(); } catch (MessagingException e) { e.printStackTrace(); } }
public void sendMail(String email) { Map<String, Object> map = new HashMap<String, Object>(); map.put("email", email); try { String text = getTextByTemplate(template, map); send(email, text); } catch (IOException | TemplateException e) { e.printStackTrace(); } catch (MessagingException e) { e.printStackTrace(); } }
public void sendMail(String email) { Map<String, Object> map = new HashMap<String, Object>(); map.put("email", email); try { String text = getTextByTemplate(template, map); send(email, text); } catch (IOException | TemplateException e) { e.printStackTrace(); } catch (MessagingException e) { e.printStackTrace(); } }
Contents.getContents(mm, i); } catch (MessagingException e) { e.printStackTrace();
e.printStackTrace(); } catch (Exception e) { e.printStackTrace();
transport.close(); } catch (MessagingException e) { e.printStackTrace();
transport.close(); } catch (MessagingException e) { e.printStackTrace();
try { simpleMessage.setFrom(fromAddress); simpleMessage.setRecipient(RecipientType.TO, toAddress); simpleMessage.setSubject(subject); simpleMessage.setText(text); Transport.send(simpleMessage); // this is where code hangs } catch (MessagingException e) { // TODO Auto-generated catch block e.printStackTrace(); Transport.close() }
fromColumn.setCellValueFactory(new Callback<CellDataFeatures<Message, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<Message, String> m) { // m.getValue() returns the Message instance for a particular TableView row try { return new ReadOnlyObjectWrapper<String>(Arrays.toString(m.getValue().getFrom())); } catch (MessagingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } });
private void deleteMessage(final Message message) { try { message.setFlag(Flags.Flag.DELETED, true); } catch (final MessagingException e) { e.printStackTrace(); } }
private boolean isTestEmail(Message message) { try { return message.getSubject().equals(TEST_EMAIL_SUBJECT); } catch (MessagingException e) { e.printStackTrace(); return false; } } }
public static void DisconnectFromRemote() { try { store.close(); } catch (MessagingException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void close() throws IOException { try { folder.close(false); } catch (MessagingException e) { e.printStackTrace(); } }
public void initParams(String val) { try { if (val != null) { params = new ParameterList(val); } else { params = DEF_LIST; } } catch (MessagingException e) { e.printStackTrace(); System.err.println(e.getMessage()); params = DEF_LIST; } }
@SuppressWarnings("unused") private void addEmailAttachements(File attachment){ bodypart = new MimeBodyPart(); DataSource source = new FileDataSource(attachment); try { bodypart.setDataHandler(new DataHandler(source)); bodypart.setFileName(attachment.getName()); multipart.addBodyPart(bodypart); } catch (MessagingException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void close() { if (store != null && store.isConnected()) { try { store.close(); } catch (MessagingException e) { e.printStackTrace(); } } }