Solved

CFPOP Attachments

Posted on 2004-10-01
9
515 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
ID: 12202984
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
ID: 12203156
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
ID: 12222390
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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 21

Expert Comment

by:pinaldave
ID: 12222430
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
 
LVL 35

Expert Comment

by:mrichmon
ID: 12222565
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
ID: 12222890
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
ID: 12227561
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
ID: 12235465
thanks so much for your help.....
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 12238398
no problem :o)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…

749 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