Hi ! I want to write a rebol app for my own use that will download email messages (and attachments, if any) in a directory. On Rebol.org there are some scripts that do this, but they fail in some cases, and I'm not experienced enough in Rebol in order to correct those scripts. Has anyone made such a script ? Thanks !
What protocol do you want to use? POP or IMAP? Rebol should support both. If you didn’t supply you network details to Rebol when you installed it, you must use the set-net word whose parameter is a block containing six values. You must put in this list: Your electronic mail address, The name or the IP address of the server for sending mail, The name or the IP address of the server for receiving mail, The name or IP address of a proxy, The port number of the proxy, The proxy type mail account name (optional) mail password (optional) You can use none, example: Code: set-net [ maxint@tiscali.it smtp.tiscali.it pop.tiscali.it proxy.domaine.fr 8080 generic maxint mypassword ] Code: set-net [ maxint@tiscali.it smtp.tiscali.it pop.tiscali.it none none none ] Rebol supports four different proxy types: socks socks4 socks5 generic If your email account name is your full email address including the @domain, it isn’t possible to use this simple form to read mail. You can have to use the slightly longer, but more readable, method of defining a mailbox: Code: mailbox: [ scheme: 'pop host: "pop.maxint.it" user: "maxint@tiscali.it" pass: "password" ] Finally you can read messages with read: Code: my_emails: read mailbox Each message is received in the form of a multi-line character string which is place in a list.
With the command import-email you can read properly each message, it creat an oject with all the fields of the email. Example: Code: >> a: import-email read %temp.eml >> probe a == make object! [ To: none CC: none BCC: none From: [maxint@tiscali.it] Reply-To: none Date: 3-Jan-2011/12:33:46+1:00 Subject: "Please ignore this message!" Return-Path: none Organization: none Message-Id: "<4D21B41A.8080602@rometec.it>" Comment: none X-REBOL: "View 2.7.8.3.1 http://WWW.REBOL.COM" MIME-Version: "1.0" Content-Type: {multipart/related; boundary="------------080306090705080 709020500"} Content: {This is an example....} ] So it's very easy extract what do you want: Code: >> a/from == [maxint@tiscali.it]
Thanks for your reply! OK, after having used the import-email function, how do I extract attachments from a message ? Also, some email messages are multipart/html or just plain text; how do I extract them ?
Thanks for your reply! Once I use the import-email function, how do I extract attachments from a message ? Also, some email messages are multipart/html or just plain text; how do I extract them ?
From http://www.codeconscious.com/rebol/rebol-scripts.html#MIMEEmailhandlingincludingattachments MIME Email handling (including attachments) inetmsg-model.r http://www.codeconscious.com/rebsite/rebol-library/inetmsg-model.r mime-model.r http://www.codeconscious.com/rebsite/rebol-library/mime-model.r encodings.r http://www.codeconscious.com/rebsite/rebol-library/encodings.r Provides a facility to parse MIME messages. Or just get the attachments out. Will handle nested multipart messages such as that sent from BeOS mailer. I believe they could also be useful for handling http form upload data, though a more lean solution might be better for this case. Also handles uuencoded messages.