Hi. I'm pretty new to the ASP part of the web developement world and need some help.

I built an ASP form that sends and works pretty musch exactly liek I want it to. The problem is that when the results of the form are emailed, you recieve a blank email. I should be receiving an email with the senders name, email, and comments. My hosting company thinks that there is something missing from that code that would make that information send or that the page that the code is .htm when it should be .asp. Could someone help me figure out whats wrong with my code so the information thats trying to be sent is actually getting sent?

Here is the code for my form (I have this in both .htm and .asp):

<form name="Testing" method="post" action="ASPEmail_confirm.asp">
<table cellpadding="2" cellspacing="2">
<td height="40" colspan="2" bgcolor="white">ASPEmail - Contact Form</td>
<td>Your Name:</td>
<td><input name="VisitorName" type="text" size="46" /></td>
<td>Your Email:</td>
<td><input name="VistorEmail" type="text" size="46" /></td>
<td valign="top">Your Message:</td>
<td><textarea name="VistorComments" cols="35" rows="10"></textarea></td>
<td align="right"><input type="submit" name="Submit" value="Submit" /></td>


this is the code for the .asp page:

DIM strVName, strVEMail, strVComments
    strVName = request.form("VisitorName")
    strVEMail = request.form("VisitorEMail")
    strVComments = request.form("VisitorComments")

%> <%
DIM Mail, strMsgHeader
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "mail.example.com"
Mail.Username = "example@example.com"
Mail.Password = "xxxxx"
Mail.From = strVEMail
Mail.FromName = strVName
Mail.AddAddress "example@example.net"
Mail.AddReplyTo strVEMail
Mail.Subject = "Email From Your Website"
Mail.Body = strVComments
On Error Resume Next
Set Mail = Nothing
IF Err <> 0 THEN
Response.Write "There has been an error and your message could not be sent at this time using this form. Please contact us directly at (xxx)xxx-xxxx. " & Err.Description
    END IF

Thank you so much.

8 Years
Discussion Span
Last Post by tomer1

Not sure what is wrong with your code but thought I could suggest a code to you which I use. Grabs all the information fine everytime:

If Request.Form.Count > 0 Then
Const cdoSendUsingMethod        = _
Const cdoSendUsingPort          = 1
Const cdoSMTPServer             = _
Const cdoSMTPServerPort         = _
Const cdoSMTPConnectionTimeout  = _
Const cdoSMTPAuthenticate       = _
Const cdoBasic                  = 1
Const cdoSendUserName           = _
Const cdoSendPassword           = _
Dim objConfig  ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields     ' As ADODB.Fields
Dim title, firstname, surname, email, confirmemail, reason, other, enquiry

title = Request.Form("title")
firstname = Request.Form("firstname")
surname = Request.Form("surname")
email = Request.Form("email")
confirmemail = Request.Form("confirmemail")
reason = Request.Form("reason")
other = Request.Form("other")
enquiry = Request.Form("enquiry")

' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
	.Item(cdoSendUsingMethod)       = cdoSendUsingPort
	.Item(cdoSMTPServer)            = "smtp.yoursite.co.uk"
	.Item(cdoSMTPServerPort)        = 25
	.Item(cdoSMTPConnectionTimeout) = 10
	.Item(cdoSMTPAuthenticate)      = cdoBasic
	.Item(cdoSendUserName)          = "you@yoursite.co.uk"
	.Item(cdoSendPassword)          = "password"

End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
	.To       = "whatever@where.com"
	.From     = "whoever@where.co.uk"
	.Subject  = "Customer Enquiry" 
	.TextBody = "SMTP Relay Test Sent @ " & Now() & vbCrLf & "title: " & title & vbCrLf & "firstname: " & firstname & vbCrLf & "surname: " & surname & vbCrLf & "email: " & email & vbCrLf & "confirmemail: " & confirmemail & vbCrLf & "reason: " & reason & vbCrLf & "other: " & other & vbCrLf & "enquiry: " & enquiry 
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
End If

I know it's not a solution but it's been useful for me!


please post your code error.

try to use this code:


' Set the mail server configuration
Set objConfig=CreateObject("CDO.Configuration")
objConfig.Fields.Item(sendUrl)=2 ' cdoSendUsingPort

' Create and send the mail
Set objMail=CreateObject("CDO.Message")
' Use the config object created above
Set objMail.Configuration=objConfig

objMail.HTMLBody= "Text"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.