Save Sent Email Using JavaMail

To Save email in your Sent Items folder using JavaMail, you need to add additional code after your email is sent. If you are connecting to GMail’s SMTP server, there is no need to since it automatically saves it to the Sent Mail folder. If you are connecting to some IMAP server, like an Exchange server, then you need to add the following code after your code that sends the email using SMTP.

Related Posts Plugin for WordPress, Blogger...

8 comments

  1. HI I tried to implement the same but while establishing a connection with imap server it gives me connection time out error .
    plz help

  2. i get following error while using this code at
    “Store store = session.getStore(“smtp”);
    store.connect(smtp_server, smtp_login, smtp_password);”
    error is:
    javax.mail.MessagingException: Connection refused: connect;

  3. i get following error while using this code at
    “Store store = session.getStore(“imap”);
    store.connect(smtp_server, smtp_login, smtp_password);”
    error is:
    javax.mail.MessagingException: Connection refused: connect;

Leave a Reply

Your email address will not be published. Required fields are marked *