the from email is entered by the user. .. here is whole sub. . .
Private Sub SendMail(ByVal from
As String,
ByVal body As
String)
Dim mailServerName
As String =
"smtpout.secureserver.net"
Dim message
As MailMessage = New MailMessage(from,
"rules@playrut.com",
"myrules", body)
Dim mailClient
As SmtpClient = New SmtpClient
mailClient.Host = mailServerName
mailClient.Send(message)
message.Dispose()
End Sub
and then at the top of the page i have the imports System.Net.Mail . . .
I just tried your code as-is, and it worked for me. That means that the issue is with the from address and that the value from txtName isn't in the format of an actual email address when the form is submitted.
ok interesting, the txtName is coming from a form wizard where a user enters their email into a text box. . . I have tried it enterting a couple different valid email addresses. . . is there something about how it is written that would be passing it along wrong?
ok I think I solved that portion of the problem. . . I now get this error though . . .
Exception Details: System.Net.Mail.SmtpFailedRecipientException: Mailbox name not allowed. The server response was: Sorry, that domain isn't in my list of allowed rcpthosts.
Source Error:
Line 15:
Line 16: mailClient.Host = mailServerName
Line 17: mailClient.Send(message)
Line 18: message.Dispose()
Line 19: End Sub
You're probably using the wrong SMTP port, which is 25 by default. You'll need to contact whoever is in charged of your mail server to find out which port you should use to send email.
slehr
Member
105 Points
21 Posts
The specified string is not in the form required for an e-mail address.???
May 05, 2006 05:15 AM|LINK
I get that error for this line of code. . .
Dim
message As MailMessage = New MailMessage(from, "rules@playrut.com", "myrules", body)I got the code from one of the tutorials. . .any idea why its not working?
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: The specified string is not in the form required for an e-mail address.???
May 05, 2006 05:26 AM|LINK
What does the from email address look like? Also, take a look at SystemWebMail.com or SystemNetMail.com depending on which namespace you are using.
HTH,
Ryan
slehr
Member
105 Points
21 Posts
Re: The specified string is not in the form required for an e-mail address.???
May 05, 2006 05:38 AM|LINK
the from email is entered by the user. .. here is whole sub. . .
Private Sub SendMail(ByVal from As String, ByVal body As String) Dim mailServerName As String = "smtpout.secureserver.net" Dim message As MailMessage = New MailMessage(from, "rules@playrut.com", "myrules", body) Dim mailClient As SmtpClient = New SmtpClientmailClient.Host = mailServerName
mailClient.Send(message)
message.Dispose()
End Suband then at the top of the page i have the imports System.Net.Mail . . .
slehr
Member
105 Points
21 Posts
Re: The specified string is not in the form required for an e-mail address.???
May 05, 2006 05:44 AM|LINK
also,
SendMail(txtName.Text, txtRule.Text) that is how I call the sendmail button in the finishclick event. . .
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: The specified string is not in the form required for an e-mail address.???
May 05, 2006 06:13 AM|LINK
I just tried your code as-is, and it worked for me. That means that the issue is with the from address and that the value from txtName isn't in the format of an actual email address when the form is submitted.
HTH,
Ryan
slehr
Member
105 Points
21 Posts
Re: The specified string is not in the form required for an e-mail address.???
May 05, 2006 06:19 AM|LINK
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: The specified string is not in the form required for an e-mail address.???
May 05, 2006 06:20 AM|LINK
Comment out the SendMail method, and replace it with this:
Response.Write(txtName.Text)
That will display what value is submitted.
Ryan
slehr
Member
105 Points
21 Posts
Re: The specified string is not in the form required for an e-mail address.???
May 05, 2006 06:44 AM|LINK
ok I think I solved that portion of the problem. . . I now get this error though . . .
Exception Details: System.Net.Mail.SmtpFailedRecipientException: Mailbox name not allowed. The server response was: Sorry, that domain isn't in my list of allowed rcpthosts.
Source Error:
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: The specified string is not in the form required for an e-mail address.???
May 05, 2006 06:53 AM|LINK
You're probably using the wrong SMTP port, which is 25 by default. You'll need to contact whoever is in charged of your mail server to find out which port you should use to send email.
HTH,
Ryan
slehr
Member
105 Points
21 Posts
Re: The specified string is not in the form required for an e-mail address.???
May 05, 2006 07:20 AM|LINK