Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

allow visitor to fill their email address and upload a file to my emai

Status
Not open for further replies.
Dec 20, 2004
34
US
I've been reading alot about ASP file attachments, I know there are many ways to do it, but I don't want to purchase any components. My hosting site is on an ASP Win2K3 server I believe. For sure it's ASP compatible. They have shown me a nice script to have visitors send me an email with the text in the body. But they didn't provide one with the option of adding an attachment. So I've been searching long and hard for a free script to do so. I've seen ASPemail, looks like it's free but it uses ASPUpload to do the attachment.

I'm looking for something that is very simple, something I don't have to ask my hosting site to change/add. I want to have a browse button for the visitor to select a file from their PC, and an email address field for them to provide (when I recieve, this email address will be in the "From" field) and a Submit, Reset button. The file and their email address will be sent to my email address.

There has to be something free out there that will do this for me. I use FrontPage 2003, it's File Upload, and Form command are how I want it to look, but I don't want the File to upload to my server, I want it in my email. I've already read the FAQ. Any suggestions, sample codes, links appreciated.
 
Active Server Pages run on the server.

If you want Active Server Pages to send a file via email then the file must exist either on the server, or is some network share accessible by the server.

Since users don't typically allow a web server free reign of their hard drives, I'm not sure how you send a file from an Active Server Page without uploading the file.

It sounds like what you really want is for the user to email a file using their local email client. If this is what you want then you are looking for a client-side solution rather than an Active Server Page.
 
Look into aspemail that may help. It is a server componant that allows email through asp
You may need to set up so that a user uploads a file to your server then it gets emailed to you and the file get deleted from the server.

Look at freeaspupload as well.

}...the bane of my life!
 
Thanks all. After the file is uploaded to the server, what would the code look like if I want the file from the server to be automatically emailed to me along with the user's email address?
 
You can use CDOSYS to send email messages. Something like the following:

set objCDO = Server.CreateObject("CDO.Message")
objCDO.To = "my@myaddress.com"
objCDO.From = Request.Form("userEmail")
objCDO.Subject = "Email from User"
objCDO.AddAttachment(fileName)
objCDO.TextBody = "Email contains attachment from user"
objCDO.Send
set objCDO = nothing

Substitute the email addresses for the proper ones and the full path to your uploaded file.

Mighty
 
Help me someone. I want to be able to recieve a user's file and have it attached and emailed to me, with the email address of the user. The email address of the user doesn't have to be in the "From" field when I recieve the email. I just want to be able to match his/her file to their email address.

Each of the codes below work but separately. I want to combine the ASP Mail Component, with the ASP FileUP Component in 1 asp page. And where do I put the code from above post to have the file emailed to me automatically when the file is uploaded.

Here's the codes that were provided by my host:

How to use CDOSYS (standard Windows Mail Component)?

<!--METADATA TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library" -->
<!--METADATA TYPE="typelib"
UUID="00000205-0000-0010-8000-00AA006D2EA4"
NAME="ADODB Type Library" -->
<%
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject("CDO.Configuration")

'Configuration:
objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort

objConfig.Fields(cdoSMTPServer)="smtp.1and1.com"
objConfig.Fields(cdoSMTPServerPort)=25
objConfig.Fields(cdoSMTPAuthenticate)=cdoBasic
objConfig.Fields(cdoSendUserName) = "mxxxxxxxx-x"
objConfig.Fields(cdoSendPassword) = "xxxxxxxx"

'Update configuration
objConfig.Fields.Update
Set objMail.Configuration = objConfig

objMail.From ="info@justonedomain.com"
objMail.To = "support@1and1.com"
objMail.Subject ="Information"
objMail.TextBody="This is a test for CDO.message"
objMail.Send

If Err.Number = 0 Then
Response.Write("Mail sent!")
Else
Response.Write("Error sending mail. Code: " & Err.Number)
Err.Clear
End If
Set objMail=Nothing
Set objConfig=Nothing
%>

objConfig.Fields(cdoSMTPServer)="smtp.1and1.com" This is the outgoing server.
objConfig.Fields(cdoSendUserName) = "mxxxxxxxx-x" Your email username. You
can find this in you Control Panel under Email Overview.
objConfig.Fields(cdoSendPassword) = "xxxxxxxx" is the email password.




How to use ASP Mail Component?

ASP Mail is an Active Server Component designed to send emails from an Active Server Page.
This component is installed on our servers.

Below is a sample asp script that use Asp Mail component to send the information from feedback form to an email address.

forminfo.asp
You can edit the following script to your requirements.


<% @LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>

<%
Set Mail = Server.CreateObject("SMTPsvg.Mailer") 'create an Asp mail component.
Mail.FromName = "1&1 Test"
Mail.FromAddress= Request.Form("email")
Mail.RemoteHost = "mrelay.perfora.net" ' The mail server you have to use with Asp Mail
Mail.AddRecipient "ABCDE Company", "hello@justonedomain.com"
Mail.Subject = "Website - Info Request"
Mail.BodyText = Request.Form("info")
if Mail.SendMail then
Response.Write "Your mail has already been sent..."
else
Response.Write "Mail send failure. Error was " & Mail.Response
end if
%>

<body>
<p>Thank You!!<br>
</body>
</html>

A basic version of a feedback form:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ASP Mail Test page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body background="">

<table width="100%" border="0" align="center">
<tr class="medium">
<td width="54%" align="center" valign="top">
<form onSubmit="return ValidateForm()" method="post" action="forminfo.asp">
Email Address:: <input name="email" type="text" id="email" size="41"></p>
Comments:: <textarea name="info" cols="35" rows="10"></textarea></p>
<input class="fancybut" type="submit" name="Submit" value="Submit Form">
<input class="fancybut" type="reset" name="Submit2" value="Reset Form"></p>
</form></td>
<td width="16%" align="right" valign="top"></td>
</tr>
</table>
</body>
</html>

The important line is:
<form onSubmit="return ValidateForm()" name="form1" method="post" action="forminfo.asp">
The action field should have the name of the aspmail component.

Mail.FromAddress= Request.Form("email") gets the email address entered in the form.
Mail.BodyText = Request.Form("info") gets the comments from the form.
Mail.AddRecipient "ABCDE Company", "hello@justonedomain.com" An email will be sent to hello@justonedomain.com

To get more information please visit Instructions on ASPMail

The script given here is a test script that you may want to incorporate into your
code. You would need to make sure that any paths referenced in the code are correct.






How to use ASP FileUP Component?




ASP FileUp allows users with a web browser to transmit files from their local
system to a MS (IIS) web server. Files can be of any format. (word, gif, etc)

The most important thing with the Asp Fileup is setting up the Path. This path
will specify the place for the files to be uploaded (saved).

In this sample "uploads\data" is the path where "Asp FileUp" will upload the
file to.

Make sure you set the write permission on the subdirectory /data.
If you dont set write permissions a "permission error" will pop up when you run the
Asp Fileup Script.
To set write permissions please follow the FAQ: How to set permissions for directories?

upload_file.asp


<% @Language=VBScript %>
<HTML>
<HEAD>
<TITLE>FileUp Upload Simple Sample</TITLE>
</HEAD>
<BODY>

<%
Dim oFileUp

'--- Instantiate the FileUp object
Set oFileUp = Server.CreateObject("SoftArtisans.FileUp")

'--- Set the Path property to the location you wish to temporarily cache the incoming file before saving
oFileUp.Path = Server.MapPath("uploads\data")

'--- Check if a file was selected (myFile is coming from the html code)
'--- If so, continue processing
If Not oFileUp.Form("myFile").IsEmpty Then

'--- Save the file
oFileUp.Form("myFile").Save

'--- The file is saved, display a confirmation message
Response.Write ("<B>File saved successfully on the server as:</B><BR>")

'--- The ServerName() property is the full path of the file where it was saved on the server
Response.Write(oFileUp.Form("myFile").ServerName)

Else
Response.Write("Error: There was no file submitted for upload.")
End If

'--- Destroy objects
Set oFileUp = Nothing
%>

</BODY>
</HTML>

A simple form will looks like this:
upload_file_form.htm


<HTML>
<HEAD>
<TITLE>FileUp Simple Upload Sample</TITLE>
</HEAD>
<BODY>
<H3 ALIGN=center>&nbsp;</H3>
<H3 ALIGN=center>Asp FileUp Upload Sample</H3>
<p ALIGN=center>&nbsp;</p>
<FORM ACTION="upload_file.asp" ENCTYPE="MULTIPART/FORM-DATA" METHOD="POST">
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="RIGHT" VALIGN="TOP">Enter Filename:</TD>

<!--
Note: Notice this form element is of TYPE="FILE"
-->
<TD ALIGN="LEFT"><INPUT TYPE="FILE" NAME="myFile" size="20"><BR>
Please click Browse to select a file.</TD>
</TR>
<TR>
<TD ALIGN="RIGHT">&nbsp;</TD>
<TD ALIGN="LEFT"><INPUT TYPE="SUBMIT" VALUE="Upload File"></TD>
</TR>
</TABLE>
</FORM>

</BODY>
</HTML>



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top