<div class=OutlookMessageHeader lang=en-us dir=ltr align=left>
From: Dillon, Mary [mailto:MDillon@fnbaonline.com]
Sent: Tuesday, March 04, 2008 2:24 PM To: Scott Mitchell Subject: RE: Sending email ASP.NET 2.0 VB code-behind
</div> <div></div> <div dir=ltr align=left>One more!</div> <div dir=ltr align=left>
Dim fromAddress
As String = txtName.Text &
", " & txtEmail.Text
Throw's an error. How do i have the from address insert the name before the email?
</div>
<div class=OutlookMessageHeader lang=en-us dir=ltr align=left>
From: Scott Mitchell [mailto:mitchell@4guysfromrolla.com]
Sent: Tuesday, March 04, 2008 3:22 PM To: Dillon, Mary Subject: RE: Sending email ASP.NET 2.0 VB code-behind
</div> <div></div> <div dir=ltr align=left>You probably don't have the SMTP stuff setup correctly on localhost. I'd try it with a remote SMTP server to make sure everything works,
then focus on diagnosing this error.</div>
<div class=OutlookMessageHeader lang=en-us dir=ltr align=left>
From: Dillon, Mary [mailto:MDillon@fnbaonline.com]
Sent: Tuesday, March 04, 2008 2:18 PM To: Scott Mitchell Subject: RE: Sending email ASP.NET 2.0 VB code-behind
</div> <div></div> <div dir=ltr align=left>Thanks!! Now I got this error :)</div> <div dir=ltr align=left>
Server Error in '/asp_dot_net_vb' Application.
Smtp server returned an invalid response.
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: Smtp server returned an invalid response.
Source Error:
Line 13: Dim message As New MailMessage(fromAddress, toAddress, subject, body)
Line 14: Dim smtp As New SmtpClient
Line 15: smtp.Send(message)
Line 16: End Sub
Line 17:
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.</div>
<div class=OutlookMessageHeader lang=en-us dir=ltr align=left>
From: Scott Mitchell [mailto:mitchell@4guysfromrolla.com] Sent: Tuesday, March 04, 2008 3:15 PM To: Dillon, Mary Subject: RE: Sending email ASP.NET 2.0 VB code-behind
</div>
<div></div>
<div dir=ltr align=left>Try putting a comma between the two email addresses in the toAddress.</div>
<div class=OutlookMessageHeader lang=en-us dir=ltr align=left>
From: Dillon, Mary [mailto:MDillon@fnbaonline.com] Sent: Tuesday, March 04, 2008 2:12 PM To: smitchell@internet.com Cc: Mary @};- Subject: Sending email ASP.NET 2.0 VB code-behind
</div>
<div></div>
<div>I followed your example and I get errors on the message as new mailmessage().</div>
<div> </div>
<div>Dim toAddress As String = "mdillon@fnbaonline.com; info@webpagedesignstudio.com"</div>
<div>Dim fromAddress As String = txtEmail.Text</div>
<div>Dim subject As String = "Quick Question!"</div>
<div>Dim body As String = txtMessage.Text</div>
<div>Dim message As New MailMessage(fromAddress, toAddress, subject, body)</div>
<div>Dim smtp As New SmtpClient</div>
<div>smtp.Send(message)</div>
<div> </div>
<div> </div>
<div>I am using my localhost with the port specified in the webconfig file.</div>
<div> </div>
<div>
<
system.net><mailSettings>
<
smtp>
<
network
host="localhost"port="2571" />
<!--
userName="username@domain"
password="xxxxxx" /> -->
</
smtp></mailSettings>
</
system.net></div>
<div> </div>
<div>
<div>I get the following message</div>
<div>
Server Error in '/asp_dot_net_vb' Application.
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 11: Dim subject As String = "Quick Question!"
Line 12: Dim body As String = txtMessage.Text
Line 13: Dim message As New MailMessage(fromAddress, toAddress, subject, body)
Line 14: Dim smtp As New SmtpClient
Line 15: smtp.Send(message)
[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) +934335
System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset) +45
System.Net.Mail.MailAddressCollection.ParseValue(String addresses) +37
System.Net.Mail.MailAddressCollection.Add(String addresses) +56
System.Net.Mail.Message..ctor(String from, String to) +185
System.Net.Mail.MailMessage..ctor(String from, String to) +117
System.Net.Mail.MailMessage..ctor(String from, String to, String subject, String body) +13
contact_us.btnSubmit_Click(Object sender, EventArgs e) in I:\WebPageDesignStudio\asp_dot_net_vb\contact_us.aspx.vb:13
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) +1746
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433 </div></div>
This email message, including any attachments, is for the sole use of the
intended recipient (s) and may contain information that is confidential,
proprietary, legally privileged, or otherwise protected by law from
disclosure. Any unauthorized review, use, copying, disclosure, or
distribution is prohibited. If you are not the intended recipient, or the
person responsible for delivering this to an addressee, you should notify
the sender immediately by telephone or by reply e-mail, and destroy all
copies of the original message.
This email message, including any attachments, is for the sole use of the
intended recipient (s) and may contain information that is confidential,
proprietary, legally privileged, or otherwise protected by law from
disclosure. Any unauthorized review, use, copying, disclosure, or
distribution is prohibited. If you are not the intended recipient, or the
person responsible for delivering this to an addressee, you should notify
the sender immediately by telephone or by reply e-mail, and destroy all
copies of the original message.
This email message, including any attachments, is for the sole use of the
intended recipient (s) and may contain information that is confidential,
proprietary, legally privileged, or otherwise protected by law from
disclosure. Any unauthorized review, use, copying, disclosure, or
distribution is prohibited. If you are not the intended recipient, or the
person responsible for delivering this to an addressee, you should notify
the sender immediately by telephone or by reply e-mail, and destroy all
copies of the original message.
maryjane9110...
Member
69 Points
128 Posts
Sending an email via ASP.NET 2.0 VB code-behind
Mar 04, 2008 09:35 PM|LINK
Thought I might share the thread:
<div dir=ltr align=left>Try:</div> <div dir=ltr align=left> </div> <div dir=ltr align=left>Dim fromAddress as String = txtEmail.Text & " (" & txtName.Text & ")"</div> <div dir=ltr align=left> </div> <div dir=ltr align=left> </div> <div dir=ltr align=left>Please direct future questions to an online messageboard at http://forums.asp.net so that others can benefit from this information exchange, as well.</div> <div dir=ltr align=left> </div> <div dir=ltr align=left>Thanks</div> <div dir=ltr align=left>Scott Mitchell
</div>mitchell@4GuysFromRolla.com
http://www.4GuysFromRolla.com/ScottMitchell