Solved

want to delete uploaded file(smartupload) after sending it with jmail

Posted on 2004-04-16
4
704 Views
Last Modified: 2012-08-13
Hello i want to delete a file, which has been uploaded with smartupload, after i have sent it with jmail. Can someone help me. My code is so far doing the upload and the sending of the uploaded file as an attachment with jmail. But now, how do i delete it?

This is my code so far

<%
'  Variables
'  *********
   Dim mySmartUpload
   Dim file
   Dim intCount
   dim FileName
   intCount=0
       
'  Object creation
'  ***************
   Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

'  Upload
'  ******
   mySmartUpload.Upload

'  Select each file
'  ****************
   For each file In mySmartUpload.Files
   '  Only if the file exist
   '  **********************
      If not file.IsMissing Then
      '  Save the files with his original names in a virtual path of the web server
      '  **************************************************************************
         file.SaveAs("/~Upload/" & file.FileName)

      '  Display the properties of the current file
      '  ******************************************
         Response.Write("Name = " & file.Name & "<BR>")
         Response.Write("Size = " & file.Size & "<BR>")
         Response.Write("FileName = " & file.FileName & "<BR>")
         Response.Write("FileExt = " & file.FileExt & "<BR>")
         Response.Write("FilePathName = " & file.FilePathName & "<BR>")
         Response.Write("ContentType = " & file.ContentType & "<BR>")
         Response.Write("ContentDisp = " & file.ContentDisp & "<BR>")
         Response.Write("TypeMIME = " & file.TypeMIME & "<BR>")
         Response.Write("SubTypeMIME = " & file.SubTypeMIME & "<BR>")
             FileName = File.FileName
         intCount = intCount + 1
      End If
   Next
   
'  Display the number of files which could be uploaded
'  ***************************************************
   Response.Write("<BR>" & mySmartUpload.Files.Count & " files could be uploaded.<BR>")

'  Display the number of files uploaded
'  ************************************
   Response.Write(intCount & " file(s) uploaded.<BR>")
%>




<%
email="XXX.XXXX"

msg = "Topic: " 


%>
<%
 Set JMail = Server.CreateObject("JMail.SMTPMail")
 JMail.ServerAddress = "xxx"
 JMail.Sender = email
 JMail.Subject = "Upload"
 JMail.AddRecipient "info@someone.de"
 JMail.AddAttachment Server.MapPath("/~Upload/" & FileName)
 JMail.Body = msg
 JMail.Execute
%>  
0
Comment
Question by:Chillipowder
  • 3
4 Comments
 
LVL 10

Accepted Solution

by:
D_M_D earned 250 total points
ID: 10842160
Just do it like this...


<%
' your code
 Set JMail = Server.CreateObject("JMail.SMTPMail")
 JMail.ServerAddress = "xxx"
 JMail.Sender = email
 JMail.Subject = "Upload"
 JMail.AddRecipient "info@someone.de"
 JMail.AddAttachment Server.MapPath("/~Upload/" & FileName)
 JMail.Body = msg
 JMail.Execute

' Call function
Call DeleteFile(Server.MapPath("/~Upload/" & FileName))
%>  

Function DeleteFile(strPathToFile)
   Dim objFSO
   Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

   If (objFSO.FileExists(strPathToFile)) = true Then
      objFSO.DeleteFile(strPathToFile)
   End If

   Set objFSO - Nothing
   Set JMail = Nothing

End Function

%>

--------
D_M_D
0
 
LVL 10

Expert Comment

by:D_M_D
ID: 10842172
Basically check if the file exists, if so delete it.  Just pass in the path and file name to the function.

Good Luck...

D_M_D
0
 

Author Comment

by:Chillipowder
ID: 10842749
Thanks, its working.
0
 
LVL 10

Expert Comment

by:D_M_D
ID: 10843188
Your welcome...
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Summernote and form validation 10 133
Question about ASP Including Files 6 58
is this a cms? 8 60
FileUp - Classic ASP 5 17
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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