Trying to Send Simple Email from a Simple Form; Using SMTP

  • Thread starter Thread starter ryguy7272
  • Start date Start date
R

ryguy7272

Can anyone tell me why the code below doesn't work?

Imports System.Net.Mail

Partial Class ContactUS
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim mail As MailMessage = New MailMessage()
mail.To.Add("(e-mail address removed)")
mail.From = New MailAddress(txtYourEmail.Text)
'mail.Subject = textsubject.Text
Dim str1 As String = ("<b>" & lblFirstName.Text & " = --") +
txtFirstName.Text & "<b>"
Dim str2 As String = ("<b>" & lblLastName.Text & " = --") +
txtLastName.Text & "<b>"
Dim str3 As String = ("<b>" & lblYourEmail.Text & " = --") +
txtYourEmail.Text & "<b>"
'Dim str4 As String = txtTelephone.Text
'Dim str5 As String = txtBestTime.Text
'Dim str6 As String = txtBody.Text
mail.Body = (str1 & "<br>" & "<br>") + str2 & "<br>" & "<br>" + str3
'& "<br>" & "<br>" + str4 & "<br>" & "<br>" + str5 & "<br>" & "<br>" + str6
'message.Body = txtBody.Text
mail.IsBodyHtml = True
Dim smtp As SmtpClient = New SmtpClient()

smtp.Host = "mail.consulting-group360.com"
smtp.Credentials = New System.Net.NetworkCredential("XXX", "XXX")
smtp.EnableSsl = True
smtp.Send(mail)

End Sub

Public Shared Function CreateConnectPermission() As SmtpPermission
Dim connectAccess As New SmtpPermission(SmtpAccess.Connect)
Console.WriteLine("Access? {0}", connectAccess.Access)
Return connectAccess
End Function

End Class

I commented out a few lines to make it a bit easier for me to read. I don't
get it. Unless my account is not set up correctly at GoDaddy, or unless
there is an issue with the password, I don't know what else to do. This
works perfect on my localhost (off the GoDaddy servers). As soon as I
deploy, nothing works.

I just can’t tell what the problem is. I don’t know if it is something in
the code or something on the GoDaddy end. I looked at several examples of
using SMTP to send email from a form, but none of the samples I tried did
anything, so I am back to this concept. This code makes sense to me; just
can’t figure out why it fails over and over.

Is it possible that I may need my IP address in the SMTP host; something
like “97.74.177.192/consulting-group360� I am now using
“mail.consulting-group360.comâ€, but I am still not able to send a simple
email from my simple form.

About 15 seconds after clicking the Send Email button, the form times out
and I get this message: ‘A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond
64.202.165.92:25’
Line 26: smtp.Credentials = New System.Net.NetworkCredential("XXX",
"XXX")
Line 27: smtp.EnableSsl = True
Line 28: smtp.Send(mail)

Obviously the XXX stuff is my username and password, from GoDaddy.

Any thoughts on this?

Thanks,
Ryan---
 
ryguy7272 said:
Can anyone tell me why the code below doesn't work?

Imports System.Net.Mail

Partial Class ContactUS
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim mail As MailMessage = New MailMessage()
mail.To.Add("(e-mail address removed)")
mail.From = New MailAddress(txtYourEmail.Text)
'mail.Subject = textsubject.Text
Dim str1 As String = ("<b>" & lblFirstName.Text & " = --") +
txtFirstName.Text & "<b>"
Dim str2 As String = ("<b>" & lblLastName.Text & " = --") +
txtLastName.Text & "<b>"
Dim str3 As String = ("<b>" & lblYourEmail.Text & " = --") +
txtYourEmail.Text & "<b>"
'Dim str4 As String = txtTelephone.Text
'Dim str5 As String = txtBestTime.Text
'Dim str6 As String = txtBody.Text
mail.Body = (str1 & "<br>" & "<br>") + str2 & "<br>" & "<br>" + str3
'& "<br>" & "<br>" + str4 & "<br>" & "<br>" + str5 & "<br>" & "<br>" + str6
'message.Body = txtBody.Text
mail.IsBodyHtml = True
Dim smtp As SmtpClient = New SmtpClient()

smtp.Host = "mail.consulting-group360.com"
smtp.Credentials = New System.Net.NetworkCredential("XXX", "XXX")
smtp.EnableSsl = True
smtp.Send(mail)

End Sub

Public Shared Function CreateConnectPermission() As SmtpPermission
Dim connectAccess As New SmtpPermission(SmtpAccess.Connect)
Console.WriteLine("Access? {0}", connectAccess.Access)
Return connectAccess
End Function

End Class

I commented out a few lines to make it a bit easier for me to read. I don't
get it. Unless my account is not set up correctly at GoDaddy, or unless
there is an issue with the password, I don't know what else to do. This
works perfect on my localhost (off the GoDaddy servers). As soon as I
deploy, nothing works.

I just can’t tell what the problem is. I don’t know if it is something in
the code or something on the GoDaddy end. I looked at several examples of
using SMTP to send email from a form, but none of the samples I tried did
anything, so I am back to this concept. This code makes sense to me; just
can’t figure out why it fails over and over.

Is it possible that I may need my IP address in the SMTP host; something
like “97.74.177.192/consulting-group360� I am now using
“mail.consulting-group360.comâ€, but I am still not able to send a simple
email from my simple form.

About 15 seconds after clicking the Send Email button, the form times out
and I get this message: ‘A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond
64.202.165.92:25’
Line 26: smtp.Credentials = New System.Net.NetworkCredential("XXX",
"XXX")
Line 27: smtp.EnableSsl = True
Line 28: smtp.Send(mail)

Obviously the XXX stuff is my username and password, from GoDaddy.

Any thoughts on this?

Thanks,
Ryan---

I'd try http://www.systemnetmail.com/ for answers.

HTH
 
Back
Top