Solved

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

Posted on 2004-04-16
4
705 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Suggested Solutions

Title # Comments Views Activity
Need help to rewrite script 3 96
Bypass cross origin issues on development site 3 89
Using Classic ASP inside HTML pages 2 63
Select case on click 3 21
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 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