One of my colleagues wanted to write a JMeter script to test IMAP. But that code failed. So I also got involved in that. JMeter BeanShell uses Java in the backend. First I tried with a Maven project. Finally I could write a code to list the IMAP folders. Java implementation is shown below.
Then we wrote a code to print IMAP folder count for JMeter BeanShell. Code is show below.
Complete Maven project is available on GitHub - https://github.com/dedunu/imapTest