Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-04-16
4
Medium Priority
?
718 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
[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
  • 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
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/…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

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