Solved

Godaddy Web Form to E-mail

Posted on 2011-03-08
10
314 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

829 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