Hello all,
I am getting the following error message.
The specified string is not in the form required for an e-mail address.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: The specified string is not in the form required for an e-mail address.
Source Error:
Line 34:
Line 35: 'Create the MailMessage object
Line 36: Dim msg As New System.Net.Mail.MailMessage()
Line 37:
Line 38: 'Assign from address |
Source File: C:\Inetpub\wwwroot\contact.aspx.vb Line: 36
Stack Trace:
[FormatException: The specified string is not in the form required for an e-mail address.]
System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset, String& displayName) +872403
System.Net.Mail.MailAddress.ParseValue(String address) +245
System.Net.Mail.MailAddress..ctor(String address, String displayName, Encoding displayNameEncoding) +87
System.Net.Mail.MailMessage..ctor() +271
contact.btnSubmit_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\contact.aspx.vb:36
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
|
The code that I am using is as follows:
Imports System.Net.Mail
Partial
Class contact
Inherits System.Web.UI.Page
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim FromName As String = "Homewares Homesite"
Dim FromEmail As String = "fizzy@homesite.org"
Dim Subject As String = "Website Submission"
Dim ToName As String = "M Fizzy"
Dim ToEmail As String = booboo@homesite.org
''This is the series of variables that will contain the data from the form
Dim aSpace, body, name, phone, email, model, comments
name = txtName.Text
phone = txtPhone.Text
email = txtEmail.Text
model = drpModel.SelectedValue
comments = txtComments.Text
aSpace =
""
body =
"At " + DateTime.Now + " a question was sent from the Housewares Homesite." & _
" Below you will find the message sent by " & name & vbCrLf & _
aSpace & vbCrLf & _
"------" & vbCrLf & _
"Name: " & name & vbCrLf & _
"Phone: " & phone & vbCrLf & _
"Email: " & email & vbCrLf & _
"Model they were interested in most: " & model & vbCrLf & _
"Comments: " & comments
''Create the SmtpClient object (assumes using localhost)
Dim smtp As New System.Net.Mail.SmtpClient("mail.techspec.org")
'Create the MailMessage object
Dim msg As New System.Net.Mail.MailMessage()
'Assign from address
msg.From =
New System.Net.Mail.MailAddress(FromEmail, FromName)
'Assign to address
msg.To.Add(
New System.Net.Mail.MailAddress(ToEmail, ToName))
'assign subject, and body
msg.Subject = Subject
msg.Body = body
'Send the message with SmtpClient
smtp.Send(msg)
''Now that the message has been sent, we'll clear out the contents of the form and render it invisible for the "Goodbye" div tag.
name =
""
phone =
""
email =
""
model =
""
comments =
""
contactForm.Visible =
False
goodBye.Visible =
True
End Sub
End
Class
My web.config file is configured as such:
<mailSettings>
<smtp from="P Fizzy">
<network host="smtp.homesite.org" password="poweroverwhelming" userName=fizzy@homesite.org />
</smtp>
</mailSettings>
Somethings to keep in mind:
- I've used this code before on another server, and it ran without any problems.
- The server that I am currently using is a Merak Mail Server, which I'm sure has some role to play in this.
For obivous reasons, I have replaced the domain names and such with fictious names.
Any advice or thoughts would be greatly appreciated, so me and my IT guy can get this page up and running.