?
Solved

Godaddy Web Form to E-mail

Posted on 2011-03-08
10
Medium Priority
?
319 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

764 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