Solved

CFPOP Attachments

Posted on 2004-10-01
9
502 Views
Last Modified: 2013-12-24
Hi all, I was wonder if someone can help me out with a problem.  I am setting up a standard CFPOP page to display a users email. I was wondering if there was any way to store the users email attachment that they receive and insert it into a SQL Database.  The final goal is to log all emails incoming and outgoing.  I figured I would use SQL2000 To store all email info this way everything can be easily searched thru by date or user and so on.  I am just lost on what to do with the attachment itself, should I store them in a database as Binary, not sure and some help or Ideas would greatly be appreciated.  I am also open to storing all attachments in a folder, I just need a way to link them to the Database Record.  Thanks for your time
0
Comment
Question by:joebox
  • 4
  • 3
  • 2
9 Comments
 
LVL 35

Expert Comment

by:mrichmon
Comment Utility
If you stored then in a folder then just store the path to the folder in the database record.  You can use cffile's attributes to get the path to where the attachment was saved....
0
 
LVL 21

Expert Comment

by:pinaldave
Comment Utility
Hi joebox,
1) it is good idea to store images into the folder. My company does that. We have images with their unique name in the database.

Sample database example:
1) nameoftheoriginalfile
2) modifiedfilename
3) datetimeinserted
4) pathstored

now we store all the files in the different folder for our usage. Well whatever the file is uploaded we rename those file with the applicationid and currenttimewithyr so it has now new uniquename.

We also save the current filename inthe database field. This is the way we have optimized our system. My company is one of the largest in USA to serve the images. That is really good as my company is not in porn business and we have so many hits.

Regards,
---Pinal
0
 

Author Comment

by:joebox
Comment Utility
I like both answers and is how i propably would have done it.  I was just curious as to if there was any benefits of storing as binary in a database, but I guess not cause noone suggested it.  Doing it the way you guys say with cffile is there anyway to only accept certain attachment extensions.  For instance not to accept any attachments with a .exe file type???  I will probably split the points with you guys unless one of you can pull thru with this answer I will also add points to it.  thanks again for all your help and ideas....  Joe
0
 
LVL 21

Expert Comment

by:pinaldave
Comment Utility
sure, what you can do is specify what kind of mime type you want to upload. It is associated iwth your CFfile and you can specify what kind of file extention you want to upload.
<cffile
   action = "upload"
   fileField = "formfield"
   destination = "full_path_name"
   nameConflict = "behavior"
   accept = "mime_type/file_type"
   mode = "permission"
   attributes = "file_attribute_or_list">
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p35.htm#wp3540091

Limits the MIME types to accept. Comma-delimited list. For example, to permit JPG and Microsoft Word file uploads:

accept = "image/jpg, application/msword"

The browser uses file extension to determine file type.


Regards,
---Pinal
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 35

Expert Comment

by:mrichmon
Comment Utility
Watch out for the accept string PinalDave mentioned.  

It is buggy and for example
accept = "image/jpg" will not allow jpeg images sent from a mac.

Personally, I would save ALL attachements.

But when displaying since you know the name of the attachment - including filetype - do not allow the user to access any restricted extention types.  Instead display a message saying something like :

Filename : XXXXXXXXXXXX.exe is a restricted filetype.  Access Denied.

This way also saves you in the case that the director/manager comes and says "I need that file".  You can then recover it on a case-by-case basis, but you prevent the majority which are not legit, but most likely viruses.
0
 

Author Comment

by:joebox
Comment Utility
mrichmon-
can you elabortate a little more, i think I like your approach better.  So what your saying is to save all attachents to a folder and when the user views thier mail, if that mail has an attachemnt with an .exe then just dont display it in thier mail message.
So once the file name is written to Database then I could do a plain <cfif mail.attachment contains "exe"> then dont display.  Is this kind of where you are going..... joe
0
 
LVL 35

Accepted Solution

by:
mrichmon earned 500 total points
Comment Utility
Yes.

I assume that in your example mail is the query name?

If so then that is the exact kind of logic.

Something like:


<cfset restrictedfiles = "exe,scr,bat">

<cfloop index="attachment" list="attachmentlist">
   <cfloop index="extension" list="restrictedfiles">
       <cfif FindNoCase(extension, attachment)>
            Access is restricted to the attachment named: <cfoutput>#attachment#</cfoutput> because it is of a restricted filetype
        <cfelse>
            Display attachment or link to attachement
        </cfif>
    </cfloop>
</cfloop>
0
 

Author Comment

by:joebox
Comment Utility
thanks so much for your help.....
0
 
LVL 35

Expert Comment

by:mrichmon
Comment Utility
no problem :o)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now