Dim ic As ApacheCommonsNet
ic.connectionDefaultTimeout = 10000
ic.IMAPsClientConnect("imap.gmail.com", 993, True, "", "", "[email protected]", "xxxx")
ic.socketOpenTimeout = 6000
' LIST / LSUB
' Boolean for subscribed only
Dim l3 As List : l3.Initialize
l3 = ic.list("[Gmail]", "*", False) ' Get children
l3 = ic.list("", "%", True) ' Parent of subscribed
l3 = ic.list("", "[Gmail]/%", False)
' SELECT
ic.select("inbox")
' SEARCH
' Search returns formatted string of message UIDs
' Use single quotes around strings inside string
Dim search As String
search = ic.search("FROM '[email protected]' SUBJECT 'You've won the lottery!'")
' FETCH
' Search sequence can be single (eg. 1,4,6), range (eg. 20:30) or mix of both
' * will list all messages (eg. 1:*)
' Last two params are start and end byte size. Use 0 to download all bytes.
Dim l2 As List : l2.Initialize
l2 = ic.fetch(search, "BODY[HEADER]", 0, 0)
Dim l3 As List : l3.Initialize
l3 = ic.fetch("1,5,10:15,28,33", "BODY[]", 0, 40)
' STORE
ic.store("60:64", "+FLAGS", "\Flagged")
' CREATE
ic.create("Henry") 'create parent - Gmail doesn't require hierarchy separator
' EXAMINE
ic.select("Henry") 'select mailbox
Log(ic.examine("Henry"))
' CHECK
ic.check()
' COPY
ic.copy("1:5", "Henry")
' DELETE
ic.delete("Rubbish")
' SUBSCRIBE / UNSUBSCRIBE
ic.subscribe("Rubbish")
ic.unsubscribe("Rubbish")
' EXPUNGE
ic.expunge()
ic.logout
ic.disconnect