B S Nayak
B S Nayak

Reputation: 170

How to get the latest email using CFIMAP

I am using the below code block in CF9 to get all the mail data,

<cfimap
    action="GETHEADERONLY"
    name="LOCAL.checkEmail"
    secure="true"
    folder="Inbox"
    server="#ImportAquireMailServer#"
    username="#ImportAquireUsername#"
    password="#ImportAquirePassword#" />

This query object provides the information about all the mails present in inbox. While doing so it takes a lot of time and also times out frequently.

Is there any way to get the latest mail only, so that it will not provide the information about all the mails and will also not run into time out situation?

Please help.

Upvotes: 0

Views: 615

Answers (1)

shemy
shemy

Reputation: 583

you may need to update the read messages to "read" like:

<cfimap action="MarkRead" connection = "Conn" messagenumber="#getHeaders.messagenumber#"> 

after the message id done with work.

so you can query the latest messages as:

 <cfquery dbtype="query" name="getMails">
  select * from getHeaders 
  where seen=<cfqueryparam value="no" cfsqltype="cf_sql_varchar"> 
</cfquery>also you can filter with received date

you can refer http://shemy-coldfusion.blogspot.in/2013/03/coldfusion-code-to-get-multiple-mail.html

Upvotes: 1

Related Questions