GMail2Notes in less than 300 lines
I admit, the headline is an attention grabber
The total number of lines is, of cause, longer. For one, I used previous code, as well
Moving data between two places is a favorite IT pasttime (believe me, there are worse ways to kill time). Since I made friends with MIME Messages before, I was wondering how that would fit together with gMail. Every eMail system has its little "specialties". To connect to gMail I used the IMAP with username and password route (which is the only one I know of for IMAP).
Most of the Googles point to " reading the inbox" which is a distinct different task from: " pulling out all your eMail". When connecting to gMail using the enhanced IMAP classes you can pull all "Folders" using
To capture all documents going after that one view is sufficient. Google abandoned the idea of "folders" and replaced them with "labels". The idea there was: a document can be in one folder only, but can have many different labels. For other email systems that might hold true, but the way folders a implemented in Notes nicely fits with the idea of labels.
Each message comes with a
The total number of lines is, of cause, longer. For one, I used previous code, as well
e.printStackTrace()
isn't error handling.
Moving data between two places is a favorite IT pasttime (believe me, there are worse ways to kill time). Since I made friends with MIME Messages before, I was wondering how that would fit together with gMail. Every eMail system has its little "specialties". To connect to gMail I used the IMAP with username and password route (which is the only one I know of for IMAP).
Most of the Googles point to " reading the inbox" which is a distinct different task from: " pulling out all your eMail". When connecting to gMail using the enhanced IMAP classes you can pull all "Folders" using
store.getDefaultFolder().list()
. There a particular folder is interesting: [Gmail]
. In Notes speak I would say: it contains the system views, most notably "All documents", "Sent" and "Spam".
To capture all documents going after that one view is sufficient. Google abandoned the idea of "folders" and replaced them with "labels". The idea there was: a document can be in one folder only, but can have many different labels. For other email systems that might hold true, but the way folders a implemented in Notes nicely fits with the idea of labels.
Each message comes with a
getLabels()
function that directly maps (with a little attention) to a NotesDocument.putInFolder(label)
call. The code isn't perfect, but can be a good starting point for your own adventure.
Read more
Posted by Stephan H Wissel on 14 January 2014 | Comments (1) | categories: IBM Notes