[mel-base-devel] multipart messages and pop3
Timothy Ritchey
tritchey at mac.com
Thu Apr 16 12:28:26 UTC 2009
I'm having an issue extracting the parts of messages, particularly
when trying to work with pop3 folders. I am wondering if I am doing
something wrong. I am trying to extract any text/plain, or text/plain
alternative from emails. The following works when I pass it an imaps
folder, but mel:parts hangs when I pass it a pop3 folder. When I break
it, it is hanging out in compute-bodystructure-using-folder, waiting
on a stream.
Am I grabbing messages the right way?
(defun find-plain-text (message)
(let ((parts (mel:parts message))
(body "Unable to process email contents"))
(dolist (p parts)
(multiple-value-bind (a b) (mel:content-type p)
(if (and (equal a :TEXT) (equal b :PLAIN))
(let ((b (mel:part-body-string p)))
(handler-case
(setf body (mel:decode-quoted-printable b))
(t ()
(setf body b))))
(progn
(when (and (equal a :MULTIPART) (equal b :ALTERNATIVE))
(find-plain-text p))))))
body))
(defun check-email (folder)
(let* ((messages (mel:messages folder)))
(dolist (message messages)
(format t "~a~%" (find-plain-text message)))))
I can call the following on the same message from the pop3 folder, and
get the raw contents fine.
(defmethod body (message)
(with-output-to-string (str)
(with-open-stream (stream (mel:message-body-stream message))
(loop for c = (read-char stream nil nil)
while c do (write-char c str)))))
Any help would be appreciated.
- T
More information about the mel-base-devel
mailing list