apriigem
asked on
Sending info from a form to an email address
I am having trouble sending email from form. I keep getting this error message:
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/contact_us.asp, line 97
800401f3
This is the script I am using:
<form name="form1" method="post" action="<%=request.serverv ariables(" SCRIPT_NAM E")%>">
<input name="uname" type="text" id="uname2">
<input name="email" type="text" id="email2">
<select name="subject" id="subject">
<option value="general_question">Q uestion 1</option>
<option value="my_site_question">Q uestion 2</option>
<option value="pricing_question">Q uestion 3</option>
</select>
<textarea name="comments" cols="35" rows="5" id="comments">
<input type="submit" name="Submit" value="Submit">
</form>
<%
If request("submit") = "Submit" Then
Set objMail = Server.CreateObject("CDONT S.NewMail" )
objMail.From = "sender@address.com"
objMail.To = "apriigem@verizon.net"
objMail.Subject = "Message Subject"
objMail.BodyFormat=0
objMail.MailFormat=0
objMail.Body = "User Name: " & request("uname") & "<br>Email:" & request("email") & "Commments: " & request("comments")
objMail.Send
Set objMail = Nothing
End If
%>
If anyone could help me figure out how to fix this, it would be great or maybe if someone could offer some easier code that would be great too. Just so ya now, I am a beginner so please don't make any responses too complicated, my head hurts when I have to think too much. Thanks in advance. :-)
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/contact_us.asp, line 97
800401f3
This is the script I am using:
<form name="form1" method="post" action="<%=request.serverv
<input name="uname" type="text" id="uname2">
<input name="email" type="text" id="email2">
<select name="subject" id="subject">
<option value="general_question">Q
<option value="my_site_question">Q
<option value="pricing_question">Q
</select>
<textarea name="comments" cols="35" rows="5" id="comments">
<input type="submit" name="Submit" value="Submit">
</form>
<%
If request("submit") = "Submit" Then
Set objMail = Server.CreateObject("CDONT
objMail.From = "sender@address.com"
objMail.To = "apriigem@verizon.net"
objMail.Subject = "Message Subject"
objMail.BodyFormat=0
objMail.MailFormat=0
objMail.Body = "User Name: " & request("uname") & "<br>Email:" & request("email") & "Commments: " & request("comments")
objMail.Send
Set objMail = Nothing
End If
%>
If anyone could help me figure out how to fix this, it would be great or maybe if someone could offer some easier code that would be great too. Just so ya now, I am a beginner so please don't make any responses too complicated, my head hurts when I have to think too much. Thanks in advance. :-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
CDO runs on Windows 2003, CDONTs does not.
Here is the code I use: I wouldn't screw around with the configuration as mentioned...alwasy seems to mess it up. All default should work fine with your host:
Code below works, I use it: uses port 25, no configuration. Had problem with configuration on local machine.
strTo = "toemail@yourdomain.com" 'Make sure the From field has no spaces.
strFrom = "fromemail@yourdomain.com"
strSubject = "Your Subject"
strBody = "The content of email"
' Create an instance of the NewMail object.
Set objCDOMail = Server.CreateObject("CDO.M essage")
' Set the properties of the object
objCDOMail.Sender = StrFrom
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.TextBody = strBody
' Some of the more useful ones I've included samples of here:
'objCDOMail.Cc = "mailto:sschofield@aspfree .com;steve @aspfree.c om" Notice this sending to more than one person!
'objCDOMail.Bcc = "sschofield@aspfree.com;st eve@aspfre e.com"
'objCDOMail.Importance = 1
'objCDOMail.AttachFile "c:\path\filename.txt", "filename.txt"
' Send the message!
objCDOMail.Send
Here is the code I use: I wouldn't screw around with the configuration as mentioned...alwasy seems to mess it up. All default should work fine with your host:
Code below works, I use it: uses port 25, no configuration. Had problem with configuration on local machine.
strTo = "toemail@yourdomain.com" 'Make sure the From field has no spaces.
strFrom = "fromemail@yourdomain.com"
strSubject = "Your Subject"
strBody = "The content of email"
' Create an instance of the NewMail object.
Set objCDOMail = Server.CreateObject("CDO.M
' Set the properties of the object
objCDOMail.Sender = StrFrom
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.TextBody = strBody
' Some of the more useful ones I've included samples of here:
'objCDOMail.Cc = "mailto:sschofield@aspfree
'objCDOMail.Bcc = "sschofield@aspfree.com;st
'objCDOMail.Importance = 1
'objCDOMail.AttachFile "c:\path\filename.txt", "filename.txt"
' Send the message!
objCDOMail.Send
ASKER
I found that the server I am using only uses CDOSYS, ASPEMail, JMail and IP Works mail. Using the code you gave me, I get this error:
CDO.Message.1 error '80040220'
The "SendUsing" configuration value is invalid.
/contact_us.asp, line 107
Maybe I have copied it incorrectly or put some stuff in the wrong place. This is what I changed it to:
<% strTo = "info@creativewedsites.com " 'Make sure the From field has no spaces.
strFrom = "info@creativewedsites.com "
strSubject = "Wedsite"
strBody = "The content of email"
Set objCDOMail = Server.CreateObject("CDO.M essage")
objCDOMail.Sender = StrFrom
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.TextBody = strBody
objCDOMail.Send
%>
I would like for the subject of the email to be whatever the user selcts from the form.
Also, I have several different fields in my form. How would I make sure that all that information is in the email? In the previous code I used I had to include all the field names in the code. I don't see that in the revised code you gave me. Help!! I am so lost!!
CDO.Message.1 error '80040220'
The "SendUsing" configuration value is invalid.
/contact_us.asp, line 107
Maybe I have copied it incorrectly or put some stuff in the wrong place. This is what I changed it to:
<% strTo = "info@creativewedsites.com
strFrom = "info@creativewedsites.com
strSubject = "Wedsite"
strBody = "The content of email"
Set objCDOMail = Server.CreateObject("CDO.M
objCDOMail.Sender = StrFrom
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.TextBody = strBody
objCDOMail.Send
%>
I would like for the subject of the email to be whatever the user selcts from the form.
Also, I have several different fields in my form. How would I make sure that all that information is in the email? In the previous code I used I had to include all the field names in the code. I don't see that in the revised code you gave me. Help!! I am so lost!!
http://www.pensaworks.com/prg_com.asp
open the script that u did check the hosting component with
it does send email
and u can use it to find out how it does this (see source code)
and then u would have a working code
:D
open the script that u did check the hosting component with
it does send email
and u can use it to find out how it does this (see source code)
and then u would have a working code
:D
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah, I went to that link and I tried that component test thingie and it wouldnt work. I kept getting an error message about using "on error resume next" so I took all that out and it still wouldnt work. I kinda don't understand what I am supposed to be doing with that. I just need some code that works.
ASKER
oh, didn't see your comment
ASKER
Used the code below:
<%
Set objEMail = Server.CreateObject("CDO.M essage")
Set objConfig = Server.CreateObject("CDO.C onfigurati on")
Set Confi = objConfig.Fields
Confi("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
Confi("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "C:\inetpub\mailroot\picku p"
Confi.Update
Set objEMail.Configuration = objConfig
objEMail.To = "apriilgem@verizon.net"
objEMail.From = Request("email")
objEMail.Subject = Request("subject")
objEMail.TextBody = Request("comments")
objEMail.Send
Set objEMail = Nothing
%>
and got this:
CDO.Message.1 error '8004020d'
At least one of the From or Sender fields is required, and neither was found.
/contact_us.asp, line 107
I know it's something I didnt do, but what?
also, I have another form I wnat to do the same thing for, but it has multiple fields that should be in the body of the email. How would I include those fields as well.
<%
Set objEMail = Server.CreateObject("CDO.M
Set objConfig = Server.CreateObject("CDO.C
Set Confi = objConfig.Fields
Confi("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
Confi("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "C:\inetpub\mailroot\picku
Confi.Update
Set objEMail.Configuration = objConfig
objEMail.To = "apriilgem@verizon.net"
objEMail.From = Request("email")
objEMail.Subject = Request("subject")
objEMail.TextBody = Request("comments")
objEMail.Send
Set objEMail = Nothing
%>
and got this:
CDO.Message.1 error '8004020d'
At least one of the From or Sender fields is required, and neither was found.
/contact_us.asp, line 107
I know it's something I didnt do, but what?
also, I have another form I wnat to do the same thing for, but it has multiple fields that should be in the body of the email. How would I include those fields as well.
ok try the code and tell me
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Using the revised code, the page seemed ok, I didn't get an error message, but then I didn't get an email either.
o kmaybe the server considered it as spam
make it like this
objEMail.To = "apriilgem@verizon.net"
objEMail.From = "apriilgem@verizon.net"
make it like this
objEMail.To = "apriilgem@verizon.net"
objEMail.From = "apriilgem@verizon.net"
ASKER
still didnt get the email
You should hardcode the email address in the code until you get this to work, and then use request object. And, sometimes the server will prevent email from being sent to the same domain, and/or the from domain needs to be the ISP domain. Try a hotmail account or something..
ASKER
Ok, so i found the code below and this seems to work except I get 2 emails instead of one
<%
Set objMessage = CreateObject("CDO.Message" )
objMessage.Subject = Request("subject")
objMessage.From = Request("email")
objMessage.To = "info@creativewedsites.com "
objMessage.TextBody = "User Name: " & request("uname") & "Commments: " & request("comments")
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sendmail.brinkster.com"
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.F ields.Upda te
objMessage.Send
%>
does anyone know how I can seperate the body of the email into seperate lines if possible. when i get the email the fields are right next to each other like this:
User Name: Jane doeCommments: sample email
<%
Set objMessage = CreateObject("CDO.Message"
objMessage.Subject = Request("subject")
objMessage.From = Request("email")
objMessage.To = "info@creativewedsites.com
objMessage.TextBody = "User Name: " & request("uname") & "Commments: " & request("comments")
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sendmail.brinkster.com"
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.F
objMessage.Send
%>
does anyone know how I can seperate the body of the email into seperate lines if possible. when i get the email the fields are right next to each other like this:
User Name: Jane doeCommments: sample email
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Depending on whether you send HTML or Text based:
TEXT - ascii chr()
objMessage.TextBody = "User Name: " & request("uname") & chr(13) & "Commments: " & request("comments")
HTML:
objMessage.TextBody = "User Name: " & request("uname") & "<br>Commments: " & request("comments")
And webtrans answer may work as well, but I always use ASCII.
TEXT - ascii chr()
objMessage.TextBody = "User Name: " & request("uname") & chr(13) & "Commments: " & request("comments")
HTML:
objMessage.TextBody = "User Name: " & request("uname") & "<br>Commments: " & request("comments")
And webtrans answer may work as well, but I always use ASCII.
ASKER
Thanks, that was easy. Ok now, i only have one more thing.
when i try to test the form I get two emails instead of one. When i tested it this morning I got the email that I had just sent, plus the one from last night that I tested. They both went to the email address at the same time. But, if I send one email right after another then I get those 2 seperate emails without a problem. I don't know if I've explained well enough for you guys to understand, but does that make any sense? Is there a solution. Thanks, you guys are super smart...I'm so lucky to have found this place. :-)
when i try to test the form I get two emails instead of one. When i tested it this morning I got the email that I had just sent, plus the one from last night that I tested. They both went to the email address at the same time. But, if I send one email right after another then I get those 2 seperate emails without a problem. I don't know if I've explained well enough for you guys to understand, but does that make any sense? Is there a solution. Thanks, you guys are super smart...I'm so lucky to have found this place. :-)
maybe that is the email server
or maybe u did submit twice
but the code as i see is ok
no duplication should occur
or maybe u did submit twice
but the code as i see is ok
no duplication should occur
What is all you code on the page now?
ASKER
THis is all the code I have on the page now:
<% @ language="VBScript" %>
<% option explicit %>
<% Dim objEMail, objMessage, Confi %>
<html>
<head>
<title>Untitled</title>
<meta http-equiv="Content-Type" content="text/html;">
<!-- Fireworks MX Dreamweaver MX target. Created Thu Aug 19 00:03:16 GMT-0400 (Eastern Standard Time) 2004-->
</head>
<body bgcolor="#ffffff">
<form name="form1" method="post" action="<%=request.serverv ariables(" SCRIPT_NAM E")%>">
<table width="467" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="202" height="35"><font size="2" face="Arial, Helvetica, sans-serif">Name:
</font></td>
<td width="265"><input name="uname" type="text" id="uname2"></td>
</tr>
<tr>
<td height="35"><font size="2" face="Arial, Helvetica, sans-serif">Email
Address: </font></td>
<td><input name="email" type="text" id="email2"></td>
</tr>
<tr>
<td height="35"><font size="2" face="Arial, Helvetica, sans-serif">Subject:
</font></td>
<td><select name="subject" id="subject">
<option value="general_question">G eneral comment/question</option>
<option value="my_site_question">Q uestion about my site</option>
<option value="pricing_question">Q uestion about pricing</option>
</select></td>
</tr>
<tr>
<td height="26" valign="bottom"><font size="2" face="Arial, Helvetica, sans-serif">Comments/Quest ions:</fon t></td>
<td rowspan="2"><textarea name="comments" cols="35" rows="5" id="comments"></textarea>< /td>
</tr>
<tr>
<td height="80" valign="top"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form></td>
<%
Set objMessage = CreateObject("CDO.Message" )
objMessage.Subject = Request("subject")
objMessage.From = Request("email")
objMessage.To = "info@creativewedsites.com "
objMessage.TextBody = "User Name: " & request("uname") & vbcrlf & "Commments: " & request("comments")
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sendmail.brinkster.com"
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.F ields.Upda te
objMessage.Send
%>
</tr>
</table>
</body>
</html>
<% @ language="VBScript" %>
<% option explicit %>
<% Dim objEMail, objMessage, Confi %>
<html>
<head>
<title>Untitled</title>
<meta http-equiv="Content-Type" content="text/html;">
<!-- Fireworks MX Dreamweaver MX target. Created Thu Aug 19 00:03:16 GMT-0400 (Eastern Standard Time) 2004-->
</head>
<body bgcolor="#ffffff">
<form name="form1" method="post" action="<%=request.serverv
<table width="467" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="202" height="35"><font size="2" face="Arial, Helvetica, sans-serif">Name:
</font></td>
<td width="265"><input name="uname" type="text" id="uname2"></td>
</tr>
<tr>
<td height="35"><font size="2" face="Arial, Helvetica, sans-serif">Email
Address: </font></td>
<td><input name="email" type="text" id="email2"></td>
</tr>
<tr>
<td height="35"><font size="2" face="Arial, Helvetica, sans-serif">Subject:
</font></td>
<td><select name="subject" id="subject">
<option value="general_question">G
<option value="my_site_question">Q
<option value="pricing_question">Q
</select></td>
</tr>
<tr>
<td height="26" valign="bottom"><font size="2" face="Arial, Helvetica, sans-serif">Comments/Quest
<td rowspan="2"><textarea name="comments" cols="35" rows="5" id="comments"></textarea><
</tr>
<tr>
<td height="80" valign="top"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form></td>
<%
Set objMessage = CreateObject("CDO.Message"
objMessage.Subject = Request("subject")
objMessage.From = Request("email")
objMessage.To = "info@creativewedsites.com
objMessage.TextBody = "User Name: " & request("uname") & vbcrlf & "Commments: " & request("comments")
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sendmail.brinkster.com"
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.F
objMessage.Send
%>
</tr>
</table>
</body>
</html>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dude, that totally worked! Thanks!
Great...glad to help!
and know for sure which components are on ur server and which are not
http://www.pensaworks.com/prg_com.asp