I am trying to write a program that could connect to email server and get email information and attachment. Is there an open source library for this?

Thanks.