Jump to content
Kaoru

Email form

Recommended Posts

Sorry, in your first post in this topic you clearly have System.Web.Mail, I didn't see your other source code further down.

<%@ Page Language="VB" %><%@ Import Namespace="System.Web.Mail" %>	Sub doEmail(Source as Object, E as EventArgs)		Dim sMsg as String		sMsg+="Name :" & txtName.Text & vbcrlf		sMsg+="Email :" & txtEmail.Text & vbcrlf		Dim objEmail as New MailMessage		objEmail.To=logan_young@hotmail.com		objEmail.From=txtEmail.Text		objEmail.Subject=txtSub.Text		objEmail.Body=sMsg		objEmail.BodyFormat = MailFormat.Text		SmtpMail.SmtpServer ="smtp.gmail.com		SmtpMail.Send(objEmail)	End Sub

Share this post


Link to post
Share on other sites

Alright, it looks like the From address is read only (heh). You have to specify it in the MailMessage constructor instead. Get rid of the line that specifies the To address and change your constructor to look like this:

Dim objEmail as New MailMessage(txtEmail.Text, "support@astralwd.co.za")

Check out this page for the constructor: http://msdn2.microsoft.com/en-us/library/14k9fb7t.aspxAnd this one for all the Members of the MailMessage object: http://msdn2.microsoft.com/en-us/library/s...ge_members.aspx

Share this post


Link to post
Share on other sites

OK, just to refresh things, here's the code I currently have:

<%@ Page Language="VB" Debug="true" %><%@ Import Namespace="System.Net.Mail" %><script runat="server">	Sub doEmail(Source as Object, E as System.Web.UI.ImageClickEventArgs)		Dim sMsg as String		sMsg+="Name :" & txtName.Text & vbcrlf		sMsg+="Message :" & txtMessage.Text & vbcrlf		Dim objEmail as New MailMessage		objEmail.IsBodyHtml = true		objEmail.To.Add(new MailAddress("support@astralwd.co.za"))		objEmail.From.Add(new MailAddress(txtEmail.Text))		objEmail.Subject=txtSub.Text		objEmail.Body=sMsg		Dim SmtpMail as SMtpClient("smtp.astralwd.co.za")		SmtpMail.Send(objEmail)	End Sub</script>

I'm getting the following compilation error:

Compiler Error Message: BC30456: 'Add' is not a member of 'System.Net.Mail.MailAddress'.Line 12: objEmail.From.Add(new MailAddress(txtEmail.Text))
Any Ideas?

Share this post


Link to post
Share on other sites
Sub doEmail(Source as Object, E as System.Web.UI.ImageClickEventArgs)		Dim sMsg as String		sMsg+="Name :" & txtName.Text & vbcrlf		sMsg+="Message :" & txtMessage.Text & vbcrlf		Dim objEmail as New MailMessage(txtEmail.Text, "support@astralwd.co.za")		objEmail.IsBodyHtml = true		objEmail.Subject=txtSub.Text		objEmail.Body=sMsg		Dim SmtpMail as SMtpClient("smtp.astralwd.co.za")		SmtpMail.Send(objEmail)	End Sub

Share this post


Link to post
Share on other sites
man, sending mail in 1.1 was much easier. :)
Hah! :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...