T
tabonni
Hi
I try to grab the checked files from HTML page and then send those PDF
files as attachments. It can just send email, there are no PDF files
attached. Can anybody point out my error?
My idea is:
When people check the check boxes in HTML page for the PDF files, it
will transfer the files' name to ASP page. Then, it will attach it in
the email.
ASP file - myMail.asp
---------------------
<%@ Language=VBScript %>
<!--METADATA TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows
Library" -->
<!--METADATA TYPE="typelib"
UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library"
-->
<%
SUB sendmail( toWho, Subject, Body )
Dim objCDO
Dim iConf
Dim Flds
Const cdoSendUsingPort = 2
Set objCDO = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
..Item(cdoSendUsingMethod) = cdoSendUsingPort
..Item(cdoSMTPServer) = "newserver"
..Item(cdoSMTPServerPort) = 25
..Item(cdoSMTPconnectiontimeout) = 10
..Update
End With
Set objCDO.Configuration = iConf
objCDO.From = "(e-mail address removed)"
objCDO.To = toWho
objCDO.Subject = Subject
courseOutline = Request.Form( "Bus" )
courseOutline = Split( courseOutline, "," )
For Each member in courseOutline
filepath = Server.Path("/") & member
objCDO.AddAttachment filepath
Next
objCDO.TextBody = Body
objCDO.Send
END SUB
toWho = TRIM( Request.Form("To") )
Subject = TRIM( Request.Form("Subject") )
Body = TRIM( Request.Form("Body") )
IF toWho <> "" THEN
sendMail toWho, Subject, Body
'Cleanup
Set ObjCDO = Nothing
Set iConf = Nothing
Set Flds = Nothing
Response.Write "Email Sent"
END IF
%>
<html>
<body>
<form action="mymail.asp" method="post" ID=Form1>
<table cellspacing=0 cellpadding=2>
<tr>
<td> From: (e-mail address removed) </td>
</tr>
<tr>
<td> To: <input type="text" name="To" size="20" ID=Text1></td>
</tr>
<tr>
<td> Subject: <input type="text" name="Subject" size="20"
ID=Text2></td>
</tr>
<tr>
<td> Attachments: </td>
<td>
<%
courseOutline = Request.Form( "Bus" )
courseOutline = Split( courseOutline, "," )
For Each member in courseOutline
response.write member & "<br>"
Next
%>
</td>
</tr>
<tr>
<td>Message: </td>
</tr>
<tr>
<td><textarea rows="10" name="Body" cols="40"
ID=Textarea1></textarea></td>
</tr>
<tr>
<td>
<%
msm = Request.Form("Test")
response.write msm
%>
</td>
</tr>
</table>
</form>
</body>
</html>
HTML file - mailform.htm
---------
<html>
<head>
<title>Request for More info</title>
</head>
<body>
<form action="mymail.asp" method="post">
<p>
MS Outlook PDF Document
<input type="checkbox" value="outlook.pdf" name="Bus" />
</p>
<p>
MS Word PDF Document
<input type="checkbox" value="word.pdf" name="Bus" />
</p>
<p>
MS Excel PDF Document
<input type="checkbox" value="excel.pdf" name="Bus" />
</p>
<p>
<input type="submit" value="Submit" name="Submit" />
</p>
</form>
</body>
</html>
I try to grab the checked files from HTML page and then send those PDF
files as attachments. It can just send email, there are no PDF files
attached. Can anybody point out my error?
My idea is:
When people check the check boxes in HTML page for the PDF files, it
will transfer the files' name to ASP page. Then, it will attach it in
the email.
ASP file - myMail.asp
---------------------
<%@ Language=VBScript %>
<!--METADATA TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows
Library" -->
<!--METADATA TYPE="typelib"
UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library"
-->
<%
SUB sendmail( toWho, Subject, Body )
Dim objCDO
Dim iConf
Dim Flds
Const cdoSendUsingPort = 2
Set objCDO = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
..Item(cdoSendUsingMethod) = cdoSendUsingPort
..Item(cdoSMTPServer) = "newserver"
..Item(cdoSMTPServerPort) = 25
..Item(cdoSMTPconnectiontimeout) = 10
..Update
End With
Set objCDO.Configuration = iConf
objCDO.From = "(e-mail address removed)"
objCDO.To = toWho
objCDO.Subject = Subject
courseOutline = Request.Form( "Bus" )
courseOutline = Split( courseOutline, "," )
For Each member in courseOutline
filepath = Server.Path("/") & member
objCDO.AddAttachment filepath
Next
objCDO.TextBody = Body
objCDO.Send
END SUB
toWho = TRIM( Request.Form("To") )
Subject = TRIM( Request.Form("Subject") )
Body = TRIM( Request.Form("Body") )
IF toWho <> "" THEN
sendMail toWho, Subject, Body
'Cleanup
Set ObjCDO = Nothing
Set iConf = Nothing
Set Flds = Nothing
Response.Write "Email Sent"
END IF
%>
<html>
<body>
<form action="mymail.asp" method="post" ID=Form1>
<table cellspacing=0 cellpadding=2>
<tr>
<td> From: (e-mail address removed) </td>
</tr>
<tr>
<td> To: <input type="text" name="To" size="20" ID=Text1></td>
</tr>
<tr>
<td> Subject: <input type="text" name="Subject" size="20"
ID=Text2></td>
</tr>
<tr>
<td> Attachments: </td>
<td>
<%
courseOutline = Request.Form( "Bus" )
courseOutline = Split( courseOutline, "," )
For Each member in courseOutline
response.write member & "<br>"
Next
%>
</td>
</tr>
<tr>
<td>Message: </td>
</tr>
<tr>
<td><textarea rows="10" name="Body" cols="40"
ID=Textarea1></textarea></td>
</tr>
</tr></td>
<tr>
<td>
<%
msm = Request.Form("Test")
response.write msm
%>
</td>
</tr>
</table>
</form>
</body>
</html>
HTML file - mailform.htm
---------
<html>
<head>
<title>Request for More info</title>
</head>
<body>
<form action="mymail.asp" method="post">
<p>
MS Outlook PDF Document
<input type="checkbox" value="outlook.pdf" name="Bus" />
</p>
<p>
MS Word PDF Document
<input type="checkbox" value="word.pdf" name="Bus" />
</p>
<p>
MS Excel PDF Document
<input type="checkbox" value="excel.pdf" name="Bus" />
</p>
<p>
<input type="submit" value="Submit" name="Submit" />
</p>
</form>
</body>
</html>