Currently in progress of completing an IMAP wrapper for Apache Commons net 3.3, it is not complete as I wrote it to implement functions I needed at the time but I will add features as I go
Not all functions and documentation implemented or tested fully yet.
1. Download commons-net-3.3.jar from Apache Commons
2. Copy the downloaded jar file from the zip to B4A or B4J libraries folder
3. Download attached library, unzip it and copy jar and xml to the libraries folder
Should catch most errors, I'll be adding more functions and tidying code as I go....
Hope it's of use to someone!
Latest version : v0.37
Implemented so far:
Useful IMAP commands HERE
v0.15 - Basic functionality - connections, fetch, search, list
v0.16 - Store, changed method names, error catching
v0.20 - Create, delete, examine mailboxes
v0.30 - Various commands added
v0.35 - Error fixes
v0.36 - Changed the way search works - now returns formatted string
v0.37 - Tidied code, fixed errors with returned values
Not all functions and documentation implemented or tested fully yet.
1. Download commons-net-3.3.jar from Apache Commons
2. Copy the downloaded jar file from the zip to B4A or B4J libraries folder
3. Download attached library, unzip it and copy jar and xml to the libraries folder
Should catch most errors, I'll be adding more functions and tidying code as I go....
Hope it's of use to someone!
Latest version : v0.37
Implemented so far:
- Connections - connect, logout, disconnect, connection timeout, socket timeout,
- append, check, copy, create, delete, examine, expunge, fetch, list, search, select, size, status, store, subscribe, uid, unsubscribe
B4X:
Dim ic As ApacheCommonsNet
ic.connectionDefaultTimeout = 10000
ic.IMAPsClientConnect("imap.gmail.com", 993, True, "", "", "xxx@gmail.com", "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 'you@email.com' 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
Useful IMAP commands HERE
v0.15 - Basic functionality - connections, fetch, search, list
v0.16 - Store, changed method names, error catching
v0.20 - Create, delete, examine mailboxes
v0.30 - Various commands added
v0.35 - Error fixes
v0.36 - Changed the way search works - now returns formatted string
v0.37 - Tidied code, fixed errors with returned values
Attachments
Last edited: