Here’s some source code for a little Scala email client. It’s nothing much, just a little wrapper that works with the JavaMail API:
If you're looking for a simple Scala IMAP client tutorial/example, please follow that link, but if you're interested in some Scala source code that demonstrates IMAP searching with Scala, JavaMail, SearchTerm, AndTerm, FromStringTerm, SentDateTerm, FlagTerm, and FetchProfile, this source code may be for you.
In short, here's what the following Scala IMAP client does:
If you ever need to write an IMAP client in Scala, I hope the following example can be helpful. For my project named SARAH (a Mac OS X Siri-like project), I wanted an IMAP client to periodically check my mail and then say something a little better than, "You've got mail", and the first part of that was getting a Scala IMAP client going.
I normally don't share source code that doesn't work, but I just want to make a note here for myself on how to use JavaMail to search for multiple search terms. While the code doesn't currently work, I believe it does show the correct syntax for searching for multiple search terms, and there's just something about the overall JavaMail API (or Yahoo Mail) that I don't understand at this moment.
While working on a Java application, I found the need for a simple Java mailbox reader. I wanted to be able to scan through one of my POP/POP3 mailboxes for messages, and then do something with those messages.
To that end I created the following example JavaMail POP mailbox reader. It connects to a standard POP/POP3 mailbox, then scans through all the messages in the "Inbox" folder.
While working on a Java application yesterday, I ran into a situation where I needed to search my POP3 mailbox for unseen messages, i.e., email messages I haven't read yet. (I'm adding some "You've got mail" functionality to one of my automated robots.)
Jumping right to the solution, here's the complete source code for a JavaMail example class that demonstrates how to search for unseen (unread) email messages in a POP/POP3 mailbox:
Today I dug into someone else's project to help fix it, and when I got to the part about sending email messages from within the program, I kept getting this JavaMail API exception:
Here's the source code for a simple "Java send mail" class that can simplify the process of sending email messages from Java applications. I've named this class
MailAgent, and I'm sharing the source code here for free. I've included a brief usage statement in the Javadoc at the top of the class. Hopefully it's all pretty straightforward, and a decent example of using the JavaMail API to send an email message.
Java Mail (JavaMail) IMAP FAQ: Can you show me how to get a list of all the email addresses in an IMAP mailbox using the Java Mail API (JavaMail API)?
Sure. Here's the source code for a Java mail (JavaMail) program that extracts all of the "from" fields out of a specified mailbox. This works for both POP3 and IMAP mailboxes.
Before going to the code, note the cool use of a
java.util.TreeSet) in this example. Based on our offline discussion, you mentioned that you really want is this: