Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8094877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:56:09+00:00 2026-06-05T20:56:09+00:00

I am trying to create a search method to attach files on my outbound

  • 0

I am trying to create a search method to attach files on my outbound emails. I need to search inside a folder and find all the files that begin with a certain character and then attach them to the email. I just need a head start on how you could create such a search method so any pointers or links to references will be appreciated.

This is What I have so far but it does not seem to work correct when I use a path instead of GetBaseTemplatePath()

<cfscript>
  attributes.attachments = 2011093475839213;
</cfscript>

<cfset Directory = "E:\sites\Example.com\FileFolder\#attributes.attachments#"> 


<cfset CurrentDirectory=Directory>  
<cfset CurrentDirectory=ListDeleteAt(CurrentDirectory,ListLen(CurrentDirectory,"/\"),"/\")>  

<cfoutput>  
 <b>Current Directory:</b> #CurrentDirectory#  
    <br />  
</cfoutput>  

<cfdirectory action="list" directory="#CurrentDirectory#" name="result">  
<cfdump var="#result#"> 

When I change the code slightly by

<cfset CurrentDirectory=GetBaseTemplatePath()> 

My code works and I get the list of all the files in my current directory. Do I have a mistake on my path that I cannot see?

This is my CFMAIL part which I do have an issue with.
When I dump my #result# query I get all the files inside the folder. Then I get this error:

The resource 2011093475839213.pdf was not found.

The root cause was: ''.

I do receive an email despite the error, just not the attached files.

<!--- 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 --->
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:56:11+00:00Added an answer on June 5, 2026 at 8:56 pm

    Something like this:

    <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>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I'm trying to do is create a method that allows a user to
I am trying to visualize how to create a search for an application that
I'm trying to find the best method to gather URLs, I could create my
I am trying to create a search function that allows the user to search
Trying to create a search method in my model and join conditions based on
I am trying to create a user-friendly method of allowing employers to search resumes
I am trying to create a class that allows search of a database to
I am trying to create a search page, this allows the admin to search
I am trying to create a quick search function on the menu of my
I'm trying to create a simple search field, what it does is it searches

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.