12

On ColdFusion 9 we are attempting to use CFIMAP to get a preview (subject, from, date) of the users email messages. We can get the data out with getHeaderOnly but doing so sets the SEEN flag as yes.

Is there a way to use CFIMAP to get a preview without marking it as SEEN?

Is this a normal feature of IMAP in general?

Tom Hubbard
  • 15,820
  • 14
  • 59
  • 86
  • 4
    In IMAP: Fetching the body with `BODY[part]` implicitly marks the seen flag, fetching it with `BODY.PEEK[part]` will prevent this behaviour. – Max Jan 14 '14 at 01:21
  • you can use the FROM,SUBJECT and SENTDATE values from the cfimap query result in getall option select * from Query_getAttachments where seen= – shemy Feb 13 '14 at 11:54
  • @shemy Does that keep the SEEN flag intact? getHeaderOnly is marking the items as seen when we perform the call. – Tom Hubbard Feb 13 '14 at 13:27
  • 1
    is SEEN different than READ? – linuxdan Sep 05 '14 at 16:06
  • 1
    The CFIMAP tag isn't capable of doing a PEEK, which is what you need to avoid tagging the mail. You might be able to use a Java class from within CF to do the particular call that you need to? – Henry Gibson Jan 05 '15 at 23:44

1 Answers1

2

We might as well get this question answered. As @HenryGibson pointed out, this is not possible with <cfimap>: it does not expose the relevant functionality. See the PEEK note on FETCH in the RFC: "6.4.5. FETCH Command". That's what you need to be able to do, and you have no control over that stuff with <cfimap>

However Java has a library for access mail stores via IMAP: IMAPStore; and looking at the docs for IMAPMessage it (unsurprisingly) supports the PEEK option on a fetch: setPeek().

So it'll definitely be doable. It's a shame <cfimap> doesn't make this simple for you though: it might be worth raising an E/R for it on the bugbase.

I think you need to give it a bash with Java, and if you run into issues, then raise a question here relevant to that. I've not personally taken the java route, so can't give you a quick "101" on it, and it's not sufficiently trivial as to really be a fit for an answer here (and I have to concede I don't have motivation to get up to speed with it enough to do so).

But <cfimap> will not be part of your solution to this, I'm afraid.

Community
  • 1
  • 1
Adam Cameron
  • 29,677
  • 4
  • 37
  • 78
  • If you do not care that it is a *server wide* setting, try setting the [`mail.imap.peek`](https://javamail.java.net/nonav/docs/api/com/sun/mail/imap/package-summary.html) mail property to true (use `imaps` for ssl). That should disable the behavior. The obvious disadvantage would be the setting applies to the entire jvm (not suitable for shared apps). Obviously it would be better for cfimap to apply it at the connection level, but .. this might be an acceptable work around for some. – Leigh Jan 11 '15 at 07:32