Jump to content

Email form


Kaoru

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

Link to comment
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

Link to comment
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?
Link to comment
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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...