在ColdFusion 9中搜索文件夹

在ColdFusion 9中搜索文件夹,coldfusion,coldfusion-9,Coldfusion,Coldfusion 9,我正在尝试创建一个搜索方法,将文件附加到我的出站电子邮件中。我需要在文件夹中搜索,找到所有以某个字符开头的文件,然后将它们附加到电子邮件中。我只是需要一个关于如何创建这样一个搜索方法的开端,这样任何指向引用的指针或链接都将受到赞赏 这是我到目前为止所拥有的,但当我使用路径而不是GetBaseTemplatePath() 尽管有错误,我还是收到了一封电子邮件,只是没有收到附件 <!--- Email Test ---> <CFMAIL FROM="user1@example.co

我正在尝试创建一个搜索方法,将文件附加到我的出站电子邮件中。我需要在文件夹中搜索,找到所有以某个字符开头的文件,然后将它们附加到电子邮件中。我只是需要一个关于如何创建这样一个搜索方法的开端,这样任何指向引用的指针或链接都将受到赞赏

这是我到目前为止所拥有的,但当我使用路径而不是
GetBaseTemplatePath()

尽管有错误,我还是收到了一封电子邮件,只是没有收到附件

<!--- Email Test --->
<CFMAIL FROM="user1@example.com" TO="user2@example.com"  SUBJECT="Test" type="HTML">
<P> This is the attachment test</P>
<p> For this test to be successful, we need to receive some file attachments with this email</p>

    <cfloop query="result">

        <cfmailparam file="#result.name#" disposition="attachment">

    </cfloop>


</cfmail>
<!--- Email Test Ends --->

这是附件测试

要使此测试成功,我们需要随此电子邮件接收一些文件附件


cfdirectory标签将允许您使用特定模式搜索文件夹。使用它返回的查询,您可以在其上循环并将所需的所有文件附加到电子邮件


cfdirectory标签将允许您使用特定模式搜索文件夹。使用它返回的查询,您可以在其上循环并将所需的所有文件附加到电子邮件


类似这样的内容:

<cfdirectory action="list" directory="#myDirectory#" name="myDir">

<cfmail subject="My Subject" to="yourAddress" from="myAddress">
  My Message
  <cfsilent>
    <cfloop query="myDir">
      <cfif Left(myDir.name,1) eq "Z">
        <cfmailparam file="#myDirectory & myDir.name#">
      </cfif>
    </cfloop>
  </cfsilent>
</cfmail>

我的留言

类似这样的内容:

<cfdirectory action="list" directory="#myDirectory#" name="myDir">

<cfmail subject="My Subject" to="yourAddress" from="myAddress">
  My Message
  <cfsilent>
    <cfloop query="myDir">
      <cfif Left(myDir.name,1) eq "Z">
        <cfmailparam file="#myDirectory & myDir.name#">
      </cfif>
    </cfloop>
  </cfsilent>
</cfmail>

我的留言

谢谢你的链接,我会尝试并让你知道。谢谢你的链接,我会尝试并让你知道。要检查第一个字符,请改为使用
left(mydir.name,1)EQ'Z'
——虽然在这种情况下你甚至不需要它,因为你可以在cfdirectory标签上使用
filter=“Z*”
。要检查第一个字符,请使用
left(mydir.name,1)EQ'Z'
——尽管在本例中您甚至不需要它,因为您可以执行
filter=“Z*”
在cfdirectory标记上。如果执行
,会发生什么情况?另外,您不需要
ListDeleteAt
之类的东西-使用DirectoryExists,我会设法绕过它,毕竟我的路径有一个错误。我将尝试使用getDirectoryFromPath,因为当涉及子目录时我遇到一些问题在我的
cfmailparam
标记上找不到
资源2011093475839213.pdf的错误。根本原因是:'.
我正在转储查询,并且该文件确实存在。我不知道为什么会出现错误。您没有指定目录。请使用
结果.目录#/#结果.名称#
@PeterBoughton是什么错误是。谢谢如果您执行
,会发生什么?另外,您不需要
ListDeleteAt
之类的东西-使用我设法用DirectoryExists绕过它,毕竟我的路径确实有一个错误。我将尝试使用getDirectoryFromPath,因为当涉及子目录时我遇到一些问题。我收到一个错误在我的
cfmailparam
标记上,找不到
资源2011093475839213.pdf。根本原因是:'.
我正在转储查询,该文件确实存在。我不知道为什么会出现错误。您没有指定目录。请使用
#result.directory#/#result.name#
@PeterBoughton是的,错误是什么。谢谢
<!--- Email Test --->
<CFMAIL FROM="user1@example.com" TO="user2@example.com"  SUBJECT="Test" type="HTML">
<P> This is the attachment test</P>
<p> For this test to be successful, we need to receive some file attachments with this email</p>

    <cfloop query="result">

        <cfmailparam file="#result.name#" disposition="attachment">

    </cfloop>


</cfmail>
<!--- Email Test Ends --->
<cfdirectory action="list" directory="#myDirectory#" name="myDir">

<cfmail subject="My Subject" to="yourAddress" from="myAddress">
  My Message
  <cfsilent>
    <cfloop query="myDir">
      <cfif Left(myDir.name,1) eq "Z">
        <cfmailparam file="#myDirectory & myDir.name#">
      </cfif>
    </cfloop>
  </cfsilent>
</cfmail>