Solved

Godaddy Web Form to E-mail

Posted on 2011-03-08
10
310 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
  • 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
 
LVL 13

Expert Comment

by:devlab2012
ID: 35071314
0
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now