Reputation: 3200
I am using CFIMAP to download email attachments daily. Despite what I have tried so far the script is reading emails from all of my folders instead from only the inbox. Anyone know how to fix this?
This is my code:
<cfimap
server = "mail.example.com"
username = "[email protected]"
action="open"
secure="yes"
password = "pass"
connection = "mail.example.com" >
<cfimap
action="GetAll"
folder="Inbox"
name="test"
attachmentpath="e:\testfolder"
GenerateUniqueFilenames="yes"
connection="mail.example.com" >
<cfimap
action="MoveMail"
newfolder="processedEmails"
stoponerror="true"
connection="mail.example.com">
<cfimap action="close" connection = "mail.example.com">
Upvotes: 3
Views: 2698
Reputation: 583
you can try the following code..
<cfimap action="open" connection="Conn" server="serverurl" username="useremail" password="passwrd" secure="yes" port="">
<cfimap action="getall" connection="Conn" name="getAttachments" folder="Inbox" attachmentpath="#GetTempDirectory()#" >
<cfquery dbtype="query" name="getMailAttachments">
select *
from getAttachments
where seen=<cfqueryparam value="no" cfsqltype="cf_sql_varchar">
and ATTACHMENTS is not null
</cfquery>
<cfloop query="getMailAttachments">
<cfimap action="MarkRead" connection = "Conn" uid="#getMailAttachments.UID#">
<cfimap action="movemail" connection = "Conn" newfolder="Read mails" uid="#getMailAttachments.UID#">
</cfloop>
Upvotes: 4