Preview email with CFIMAP without marking the SEEN flag?
Asked Answered
I

1

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?

Irrelevance answered 13/1, 2014 at 21:32 Comment(5)
In IMAP: Fetching the body with BODY[part] implicitly marks the seen flag, fetching it with BODY.PEEK[part] will prevent this behaviour.Pepito
you can use the FROM,SUBJECT and SENTDATE values from the cfimap query result in getall option <cfimap action="open" connection="Conn" server="imap.gmail.com" username="uname" password="pwd" secure="yes" > <cfimap action="getall" connection="Conn" name="Query_getAttachments" folder="Inbox" > <cfquery dbtype="query" name="getMailAttachments" > select * from Query_getAttachments where seen=<cfqueryparam value="no" cfsqltype="cf_sql_varchar"> </cfquery> <cfdump var="#getMailAttachments#">Passed
@Passed Does that keep the SEEN flag intact? getHeaderOnly is marking the items as seen when we perform the call.Irrelevance
is SEEN different than READ?Marcimarcia
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?Vickeyvicki
D
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.

Deborahdeborath answered 10/1, 2015 at 16:48 Comment(1)
If you do not care that it is a server wide setting, try setting the mail.imap.peek 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.Chesna

© 2022 - 2024 — McMap. All rights reserved.