我每天都在使用CFIMAP下载电子邮件附件。尽管到目前为止我已经尝试过,但脚本只是从收件箱中读取所有文件夹中的电子邮件。任何人都知道如何解决这个问题?
这是我的代码:
<cfimap
server = "mail.example.com"
username = "user@sexample.com"
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">
答案 0 :(得分:4)
您可以尝试以下代码..
<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>