Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-04-16
4
Medium Priority
?
727 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

963 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