I have been using this program for a while to share pictures amongst the family members around the world. This program is an excellent program. After using it for some times, I just thought it is even better if a notification can be sent immediate after the upload that I don't have to send a separate email every time I upload. Below is a sample of the code I added to the Sub Upload(process) routine in the program. The testing has told me that the email notification is sent, but the email never gets to my mailbox.
Do I have the code placed incorrectly? Where should it be placed?
...
result = fileTransfer.Upload()
Select Case result
Case 0
''''' Construct email.
Set objMailer = server.createobject("SMTPsvg.Mailer")
objMailer.FromAddress = "..."
objMailer.AddRecipient "...", "..."
objMailer.FromName = "..."
objMailer.Subject = "..."
objMailer.BodyText = "..."
objMailer.RemoteHost = "..."
Response.Write fileTransfer.uploadedFileName & " uploaded
"
Response.Write FormatSize(fileTransfer.uploadedFileSize) & " (" & fileTransfer.uploadedFileSize & " bytes) written
"
Response.Write "Content type: " & fileTransfer.contentType
If objMailer.SendMail Then
Response.Write "
Email notification sent!"
Else
Response.Write "Email failed - " & objMailer.Response
End If
Set objMailer = Nothing
Response.Write "<script language=""javascript"">opener.Command('Refresh');</script>"
Case 1
...
Case 2
...
Case 3
...
End Select
...
Theresa
1/7/2003 7:11 AM
The code for the email object seems right but you should
comment out line 1076 which is "on error resume next" so that you can catch any possible error messages.
Cem Alacayir
1/9/2003 10:52 PM
It's now working! Thank very much for your help.
Theresa
1/17/2003 9:02 PM
Please share this info with the rest of us. My customer would like to be notified when a document gets added or updated.
Ken
2/11/2003 2:18 PM
You just have to add your email component specific code to the Upload() function.
Cem Alacayir
2/11/2003 8:49 PM
If anyone could send me the code for this i would be most grateful!
beau@pcpostal.com
beau
4/30/2003 12:18 AM
Please send me the code for email notification after download!!! PLEASE PLEASE
daniele@studiolodetti.it
Daniele
11/24/2003 11:59 AM
I try the code of Theresa but the email never gets to my mailbox, so i try to comment out the line 1076 "on error resume next"
Can you specificate which on "error resume next" that of Upload() function? or another?
PLEASE HELP ME
daniele@studiolodetti.it
Daniele
11/25/2003 3:45 AM
Hi, here is the Sub Upload(process) routine with my own e-mail notification code:
' Uploads a file
Sub Upload(process)
Dim fileTransfer, result, objMailer
on error resume next
Set fileTransfer = New pluginFileTransfer
If err.number<>0 Then Error "File Transfer Plugin Error", "Plugin cannot be initialized. Please make sure that the components required by the plugin is installed on the server.", true
If process Then targetPath = WexMapPath(Request.QueryString("folder"))
HtmlHeader appName
%>
<table border=0 cellspacing=0 cellpadding=0 width=100%>
<tr class=titleRow>
<td align=left>
<span class=boldText>Upload</span> - <%=FSO.GetBaseName(targetPath)%>
</td>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=0 width=100% height=80%>
<tr align=center class=lightRow>
<td valign=middle>
<span class=boldText>
<%
' Actual upload process
If process Then
fileTransfer.path = targetPath
result = fileTransfer.Upload()
Select Case result
Case 0
''''' Construct email.
Set objMailer = server.createobject("SMTPsvg.Mailer")
objMailer.FromAddress = "..."
objMailer.AddRecipient "...", "..."
objMailer.FromName = "..."
objMailer.Subject = "..."
objMailer.BodyText = "..."
objMailer.RemoteHost = "..."
Response.Write fileTransfer.uploadedFileName & " uploaded
"
Response.Write FormatSize(fileTransfer.uploadedFileSize) & " (" & fileTransfer.uploadedFileSize & " bytes) written
"
Response.Write "Content type: " & fileTransfer.contentType
If objMailer.SendMail Then
Response.Write "
Email notification sent!"
Else
Response.Write "Email failed - " & objMailer.Response
End If
Set objMailer = Nothing
Response.Write "<script language=""javascript"">opener.Command('Refresh');</script>"
Case 1
Response.Write "No file uploaded!"
Case 2
Response.Write "Path not found!"
Case 3
Response.Write fileTransfer.uploadedFileName & " can not be written!"
End Select
%>
</span>
<form name=formBuffer method=post action="<%=scriptName%>">
<input type=hidden name=command value="Upload">
<input type=hidden name=folder value="<%=Request.QueryString("folder")%>">
</form>
<%
Else
%>
<form enctype="multipart/form-data" name=formBuffer method=post action="<%=scriptName%>?precommand=ProcessUpload&folder=<%=server.URLEncode(Request.Form("folder"))%>&popup=true">
<input type=file name=file class=formClass>
</form>
<%
End If
%>
</td>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=0 width=100%>
<tr class=titleRow>
<td align=center>
<a href="javascript:Upload();">Upload</a> " <a href="javascript:this.close();">Close</a>
</td>
</tr>
</table>
<%
Set fileTransfer = Nothing
HtmlFooter
DestroyApp()
End Sub
If the above routine does not work your web server may have a different mail component other than the one (SMTPsvg.Mailer) used in the code, or may have none.
Firstly, find out if there is any mail component installed on your web server. Secondly, find out what mail component it is if one is installed. Thirdly, if the component is different from the one in the code replace "SMTPsvg.Mailer" with the correct object name, and the following lines with the correct methods provided by your object:
objMailer.FromAddress = "..." objMailer.AddRecipient "...", "..." objMailer.FromName = "..."
objMailer.Subject = "..."
objMailer.BodyText = "..."
objMailer.RemoteHost = "..."
Hope this helps.
Theresa
1/21/2004 5:54 AM
If you often upload or download files greater than 1.2M consider setting "Server.ScriptTimeout" in the config.asp file to a higher value. I have mine set to 300 seconds, and always keep the file below 1.4M in size.
Theresa
1/21/2004 6:08 AM
Sorry! I meant I have mine set to 14400 seconds.
Theresa
1/22/2004 3:34 AM