Solved

CFPOP Attachments

Posted on 2004-10-01
9
517 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

705 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