Solved

Godaddy Web Form to E-mail

Posted on 2011-03-08
10
317 Views
Last Modified: 2012-05-11
I have a windows hosted account on godaddy.com with IIS7 running on integrated mode, but can't get the cdosys sendmail to work.  Any thoughts or suggestions?
<%@ Language=VBScript %>
<html>
<head>
</head>
<body>
<%
// language -- C#
// import namespace
using System.Web.Mail;

private void SendEmail()
{
   const string SERVER = "relay-hosting.secureserver.net";
   MailMessage oMail = new System.Web.Mail.MailMessage();
   oMail.From = "info@ms.com";
   oMail.To = "ms@hotmail.com";
   oMail.Subject = "Test email subject";
   oMail.BodyFormat = MailFormat.Html; // enumeration
   oMail.Priority = MailPriority.High; // enumeration
   oMail.Body = "Sent at: " + DateTime.Now;
   SmtpMail.SmtpServer = SERVER;
   SmtpMail.Send(oMail);
   oMail = null; // free up resources
}

%>
</body>
</html>

Open in new window

0
Comment
Question by:sargo22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 15

Expert Comment

by:pateljitu
ID: 35070793
Looks like you are using Classic ASP for email integration, use provided code for email.

set cdoMessage = Server.CreateObject("CDO.Message")

set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "relay-hosting.secureserver.net"
cdoConfig.Fields.Update

set cdoMessage.Configuration = cdoConfig
cdoMessage.From = "from@mydomain.com"
cdoMessage.To = to@mydomain.com
cdoMessage.Subject = "Feedback"
cdoMessage.Body = message
cdoMessage.Send
set cdoMessage = Nothing
set cdoConfig = Nothing

Open in new window

0
 

Author Comment

by:sargo22
ID: 35070943
I tried that and still no luck.  I should be able to go right to the asp page and it should send an e-mail correct?
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 15

Expert Comment

by:pateljitu
ID: 35071355
Try this code.

Also do you receive any error while accessing ASP page.
<%@ Language=VBScript %>
<html>
<head>
</head>
<body>
<%

set cdoConfig = Server.CreateObject("CDO.Configuration")
	
With cdoConfig.Fields
		
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "relay-hosting.secureserver.net"
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
	.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

	.Update
End With


Set CDOMessage = CreateObject("CDO.Message")
With CDOMessage
	Set .Configuration = cdoConfig

	.From = "info@ms.com"
	.To = "ms@hotmail.com"
	.Subject = "Test email subject"
	.HtmlBody = "Sent at: " + DateTime.Now
	.Send
End With

Set CDOMessage = Nothing
set cdoConfig = Nothing
%>
</body>
</html>

Open in new window

0
 

Author Comment

by:sargo22
ID: 35071554
I tried the new code and I still get an internal server error 500.  Would adding a redirect help?
0
 
LVL 15

Expert Comment

by:pateljitu
ID: 35072011
Lets try error trapping and see where code fails.
<%@ Language=VBScript %>
<html>
<head>
</head>
<body>
<%
on error resume next
set cdoConfig = Server.CreateObject("CDO.Configuration")
	
With cdoConfig.Fields
		
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "relay-hosting.secureserver.net"
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
	.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

	.Update
End With

If (err.Number <> 0) Then 
	Response.Write(err.Description &" Error 1<br />")
	err.Number = 0
end if

Set CDOMessage = CreateObject("CDO.Message")
With CDOMessage
	Set .Configuration = cdoConfig

	.From = "info@ms.com"
	.To = "ms@hotmail.com"
	.Subject = "Test email subject"
	.HtmlBody = "Sent at: " + DateTime.Now
	.Send
End With

If (err.Number <> 0) Then 
	Response.Write(err.Description &" Error 2<br />")
	err.Number = 0
end if

Set CDOMessage = Nothing
set cdoConfig = Nothing
%>
</body>
</html>

Open in new window

0
 

Author Comment

by:sargo22
ID: 35072886
The transport failed to connect to the server. Error 2
0
 
LVL 15

Expert Comment

by:pateljitu
ID: 35073210
Code seems to be working fine in this case, looks like configuration issue with GoDaddy. If they provided with username and password for your SMTP setup, please add line as provided in code attached i.e. username and password.

Godaddy forum:
http://community.godaddy.com/groups/email/forum/topic/cdo-message-1-error-80040213/

Also:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_23853223.html
With cdoConfig.Fields
		
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "relay-hosting.secureserver.net"
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
	.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
	.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")="anymail@coolexample.com" //Replace this with provided username from Godaddy
	.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")="emailpassword" //Replace this with provided password from Godaddy

	.Update
End With

Open in new window

0
 

Author Comment

by:sargo22
ID: 35073618
Object required Error 2   - Not sure why I'm getting this error
0
 
LVL 15

Accepted Solution

by:
pateljitu earned 500 total points
ID: 35074184
For error "Object required" replace this line of code
.HtmlBody = "Sent at: " + DateTime.Now
with
.HTMLBody = "Sent at: " & Now()
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question