Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How can i convert a Generic list to DataTable in c# 3 457
Classic ASP + JS 4 67
ASP Classic - Load test 2 33
Select distinct 25 60
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now