View Full Version : Need Help With attaching a file in web form through ASP
dean_z
10-28-2009, 12:34 AM
Hello,
I am having an issue and I am not so sure how to solve it. I have created a web form for an internal server. What the form does when submitted is takes the info and sends an email to specified people. In order to have proper functionallity because it is for technical issues, I need my folks to be able to attach a document to it... When I tested the form, it did not work properly... no error... and I am not sure what happened... Here is the code I am using. I know I am missing something because it works if i take attachment option out... but I cannot figure it out... any help would be appreciated by any of you! Thanks... Dean.
<%
'Dim
body = "<TABLE>"
body = body + "<TR><TD colspan=""2"">Message: Tech Support, Please open ticket and escalate to the appropriate Department </TD></TR>"
body = body + "<TR><TD colspan=""2"">Reporting Errors to Tech Support (516)237-6077 </TD></TR>"
body = body + "<TR><TD>Date and Time: </TD><TD>" + Request.Form("Submitted_DT") + " </TD></TR>"
body = body + "<TR><TD colspan=""2"">__________Impacted users information__________ </TD></TR>"
body = body + "<TR><TD>Agent(s) Atlas ID: </TD><TD>" + Request.Form("Users_ID") + " </TD></TR>"
body = body + "<TR><TD>Agent(s) Name: </TD><TD>" + Request.Form("Users_Name") + " </TD></TR>"
body = body + "<TR><TD>System Impacted: </TD><TD>" + Request.Form("Users_System") + " </TD></TR>"
body = body + "<TR><TD>System login/username: </TD><TD>" + Request.Form("Users_LoginID") + " </TD></TR>"
body = body + "<TR><TD>Agent(s) Avaya Ext: </TD><TD>" + Request.Form("Users_EXT") + " </TD></TR>"
body = body + "<TR><TD>Avaya Switch Location: </TD><TD>" + Request.Form("Users_Switch") + " </TD></TR>"
body = body + "<TR><TD>Terminal Server(s): </TD><TD>" + Request.Form("Users_Server") + " </TD></TR>"
body = body + "<TR><TD>Summary of Issue: </TD><TD>" + Request.Form("Ticket_issue") + " </TD></TR>"
body = body + "<TR><TD colspan=""2"">_______________Reported by_______________ </TD></TR>"
body = body + "<TR><TD>Name: </TD><TD>" + Request.Form("Submitter_Name") + " </TD></TR>"
body = body + "<TR><TD>ID: </TD><TD>" + Request.Form("Submitter_ID") + " </TD></TR>"
body = body + "<TR><TD>Email Address: </TD><TD>" + Request.Form("Submitter_EMAIL") + " </TD></TR>"
body = body + "<TR><TD>Phone Number: </TD><TD>" + Request.Form("Submitter_Phone") + " </TD></TR>"
set mailbot = Server.CreateObject("CDO.message")
mailbot.To = "TechSupport@domain.com" + "," + Request.Form("BRIDGE") + "," + Request.Form("SCHEDULING") + "," + Request.Form("web_18f") + "," + Request.Form("web_18B")
mailbot.CC = "HANHelpDesk@domain.com" + "," + Request.Form("Submitter_EMAIL") + "," + "Sr.ManagersCE-All@domain.com" + "," + Request.Form("PAYROLL") + "," + Request.Form("SSM_18F") + "," + Request.Form("SSM_GFGB") + "," + Request.Form("SSM_MB")
'mailbot.BCC =
mailbot.From = "HANHelpDesk@domain.com"
mailbot.Subject = Request.Form("subject_line")
mailbot.HTMLBody = body
mailbot.Send
set mailbot = nothing
response.redirect "open_ticketTY.htm"
Old Pedant
10-28-2009, 06:00 AM
Ummm...I see no code at all there where you even attempt to attach a file to the email.
So what are you talking about???
dean_z
10-28-2009, 03:19 PM
I am so sorry... had to take it out and didn't realize it wasn't back in there... we were doing some testing...but anyhows... here's the code that was in there for the attachment.
body = body + "<TR><TD>Screenshot: </TD><TD>" + Request.Form("fileupload") + " </TD></TR>"
Any help would really be appreciated.
Dean
Mike_O
10-28-2009, 05:58 PM
Hi Dean,
Looks like what you're missing is calling the CDO.message object's AddAttachment(...) function prior to sending. You'll find examples here: http://www.w3schools.com/asp/asp_send_email.asp
So, your code would be something like this:
.
.
mailbot.HTMLBody = body
mailbot.AddAttachment Request.Form("fileupload")
mailbot.Send
set mailbot = nothing
.
.
Regards,
Mike
joshl
12-24-2009, 04:50 PM
We added mailbot.AddAttachment Request.Form("fileupload") as advised. The form will now send the email with the form fields responses IF we do not add an attachment.
However, if we add an attachment the page does not submit. Get this error
CDO.Message.1 error '800c000d'
The specified protocol is unknown.
/hd/thd/open_ticket.asp, line 33
Any help is very appreciate. I posted the asp and html pages.
Here is the ASP page
<%
'Dim
body = "<TABLE>"
body = body + "<TR><TD colspan=""2"">Message: Tech Support, Please open ticket and escalate to the appropriate Department </TD></TR>"
body = body + "<TR><TD colspan=""2"">Reporting Errors to Tech Support (999)111-9999 </TD></TR>"
body = body + "<TR><TD>Date and Time: </TD><TD>" + Request.Form("Submitted_DT") + " </TD></TR>"
body = body + "<TR><TD colspan=""2"">__________Impacted users information__________ </TD></TR>"
body = body + "<TR><TD>Agent(s) Atlas ID: </TD><TD>" + Request.Form("Users_ID") + " </TD></TR>"
body = body + "<TR><TD>Agent(s) Name: </TD><TD>" + Request.Form("Users_Name") + " </TD></TR>"
body = body + "<TR><TD>System Impacted: </TD><TD>" + Request.Form("Users_System") + " </TD></TR>"
body = body + "<TR><TD>System login/username: </TD><TD>" + Request.Form("Users_LoginID") + " </TD></TR>"
body = body + "<TR><TD>Agent(s) Avaya Ext: </TD><TD>" + Request.Form("Users_EXT") + " </TD></TR>"
body = body + "<TR><TD>Avaya Switch Location: </TD><TD>" + Request.Form("Users_Switch") + " </TD></TR>"
body = body + "<TR><TD>Terminal Server(s): </TD><TD>" + Request.Form("Users_Server") + " </TD></TR>"
body = body + "<TR><TD>Summary of Issue: </TD><TD>" + Request.Form("Ticket_issue") + " </TD></TR>"
body = body + "<TR><TD colspan=""2"">_______________Reported by_______________ </TD></TR>"
body = body + "<TR><TD>Name: </TD><TD>" + Request.Form("Submitter_Name") + " </TD></TR>"
body = body + "<TR><TD>ID: </TD><TD>" + Request.Form("Submitter_ID") + " </TD></TR>"
body = body + "<TR><TD>Email Address: </TD><TD>" + Request.Form("Submitter_EMAIL") + " </TD></TR>"
body = body + "<TR><TD>Phone Number: </TD><TD>" + Request.Form("Submitter_Phone") + " </TD></TR>"
body = body + "<TR><TD>Screenshot: </TD><TD>" + Request.Form("fileupload") + " </TD></TR>"
set mailbot = Server.CreateObject("CDO.message")
mailbot.To = "name@domain.com"
mailbot.CC = "name@domain.com"
'mailbot.BCC =
mailbot.From = "name2@domain.com"
mailbot.Subject = Request.Form("subject_line")
mailbot.HTMLBody = body
mailbot.AddAttachment Request.Form("fileupload")
mailbot.Send
set mailbot = nothing
response.redirect "open_ticketTY.htm"
%>
Here is the HTML page
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Open Ticket</title>
</head>
<body>
<form method="post" action="open_ticket.asp">
<table border="1" width="100%" id="table1">
<tr>
<td colspan="2" bgcolor="#008000"><b>
<font face="Verdana" color="#FFFFFF">Open Ticket with Tech Support</font></b></td>
</tr>
<tr>
<td width="34%"><font face="Verdana">Describe Issue and any temporary fix:
</font>
<p>
<font face="Verdana">
<textarea rows="8" name="Ticket_issue" cols="31"></textarea></font></td>
<td width="64%"><font face="Verdana" size="5">Please send screenshot in
reply-all via e-mail.</font><p>
<input type="file" name="fileupload" size="20"></td>
</tr>
<tr>
<td bgcolor="#008000" width="34%">
<font face="Verdana" color="#FFFFFF"><b>Reported by</b></font></td>
<td bgcolor="#008000" width="64%"><b>
<font face="Verdana" color="#FFFFFF">Impacted Users </font></b></td>
</tr>
<tr>
<td width="34%"><font face="Verdana">Your Name: <input type="text" name="Submitter_Name" size="22"></font><p>
<font face="Verdana">Your Atlas ID: <input type="text" name="Submitter_ID" size="22"></font></td>
<td width="64%"><font face="Verdana"><b>Please separate multiple entries with
commas </b> <br>
Employee ID: <input type="text" name="Users_ID" size="59">
<br>
<i>Example: 1234, 9999, 0000, etc.</i><br>
Agent Name: <input type="text" name="Users_Name" size="59"></font></td>
</tr>
<tr>
<td width="34%"><font face="Verdana">Your E-Mail:
<input type="text" name="Submitter_EMAIL" size="22" value="@domain.com"></font></td>
<td width="64%"><font face="Verdana">Avaya Exts: (if applicable) <input type="text" name="Users_EXT" size="59"><br>
Phone Location: <input type="text" name="Users_Switch" size="13" value="Default"></font></td>
</tr>
<tr>
<td width="34%"><font face="Verdana">Your Phone#: <input type="text" name="Submitter_Phone" size="22"></font></td>
<td width="64%"><font face="Verdana">Systems impacted:
<input type="text" name="Users_System" size="17"><br>
<i>examples, etc</i>.</font></td>
</tr>
<tr>
<td width="34%"><font face="Verdana">Date and Time:<input type="text" name="Submitted_DT" size="22"></font></td>
<td width="64%"><font face="Verdana">System login/user name: <input type="text" name="Users_LoginID" size="48"><br>
<i>Example: etc.</i></font></td>
</tr>
<tr>
<td width="34%"><font face="Verdana">E-mail Subject line:
<input type="text" name="subject_line" size="41" value="Please open ticket"></font></td>
<td width="64%"><font face="Verdana">Server: <input type="text" name="Users_Server" size="59"><br>
<i>Click </i></font></td>
</tr>
<tr>
<td colspan="2">
<p style="line-height: 150%"><font face="Verdana">Send ticket to: Tech Support; <input type="checkbox" name="BRIDGE" value="group1@domain.com" id="fp3">Bridge-All;
<input type="checkbox" name="SCHEDULING" value="group2@domain.com" id="fp2">Scheduling-All;
<input type="checkbox" name="web_1" value="group3@domain.com">
1 Web Issue;
<input type="checkbox" name="web_2" value="group5@domain.com">2
Web Issue; <br>
CC: group; Group; group; <br>
<input type="checkbox" name="PAYROLL" value="group6@domain.com" id="fp1">Payroll;
<input type="checkbox" name="man1@domain.com" value="man2@domain.com" id="fp4">
Managers1;
<input type="checkbox" name="man2" value="S&S-man2@domain.com" id="fp5">man3;
<input type="checkbox" name="man3" value="S&S-man3@domain.com" id="fp6">man4</font></td>
</tr>
<tr>
<td colspan="2">
<p align="center"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>
Old Pedant
12-25-2009, 05:15 AM
No no no...you can *NOT* do it that way.
You *MUST* use an UPLOAD component and *first* upload the file to the server computer, save it (as a temp file is okay), and *THEN* attach it to the email.
So first check if your ISP has an upload component that you can use (many do). If so, use it. If not, there are some slower but adequate uploaders written entirely in VBScript code that are usable. I don't recommend them if another uploader is available.
joshl
12-28-2009, 01:59 PM
Let me clarify what we want. We want a web form that is filled out, and it needs to have an upload component. So that when they hit submit, the form info AND the uploaded file are emailed.
I used the frontpage upload component but as I said, it won't email if we attach a file.
<input type="file" name="fileupload" size="20">
Old Pedant
12-28-2009, 06:24 PM
So *IS* the web host you are using fully FP compatible?? Does it have the FP uploader installed??
If not, then you will have to use your own component. Or whatever component your host supports.
But in any case, you must *FIRST* upload the file, SAVE it on the server machine, and *THEN* attach it.
Have you googled for the FP method??
http://www.bing.com/search?q=frontpage+upload&src=IE-SearchBox
Again, all that is a waste of time if your host/server does not have the FP stuff installed.
joshl
01-06-2010, 09:33 PM
The frontpage extensions are installed, im not sure how to tell if the uploader compenent is installed. do you know how to check?
is there any method to do this if the server does not have the component installed?
Old Pedant
01-06-2010, 10:33 PM
You can do it with the so-called "Pure ASP Uploaders". Several of them out there.
Written entirely in VBScript, so you don't have to install a component on the server.
You know, it's not clear to me from reading the FP docs that you *can* do anything other than upload a file using FP. That is, I don't see how you can have both a <form> with various text fields, checkboxes, etc., *and* have the file upload.
Whereas with the more conventional components--including *MOST* of the "Pure ASP" ones--you can do so. But they do take special coding, so be sure to read the docs carefully. And don't choose one that doesn't come with FULL docs and at least one good example.
Old Pedant
01-06-2010, 10:38 PM
Ehhh...but then there is this site:
http://www.pixelmill.com/support/al1057/kb101361.htm
Says it should be easy.
I just dunno. I don't use FP. Tried it once and hated what it did to my code.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.