Send Email and AutoResponse - Help I'm doing

Ghvzqvfnwrrnt

New Member
Hi new to .NET and I almost have this working but I'm doing a few things wrong. *Its a autoresponse and form collection (by the way*).<BR><BR>1) How do I collect information from a <asp:dropdownlist/>??<BR> I'm trying to collect information from the City List but I am not collecting it for some reason. <BR><BR>2) I am getting confused with how to send the information. The user should receive a Hi, " & Name.Text & " we received your message and will answer it in a prompt manner. And I should be getting the information that was input by the user.<BR><BR>As I have it now I am getting the information from the user but the user is not getting the automated response. I have been fiddling with this for awhileam now am just confused. Could someone let me know where I'm going wrong. I pretty sure it something basic. I think I'm doing something wrong with my <BR><BR>SmtpMail.SmtpServer = "mail.networks-plus.org" <BR> SmtpMail.Send(MyMail) <BR> SmtpMail.Send(Mail)........I think this is wrong??<BR>My Code *****************************<BR><BR><%@ Import Namespace= "System.IO" %><BR><%@ Import Namespace="System.Web.Mail" %><BR><%@ Page Language="VB" Debug="true" %><BR><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><BR><HTML><BR> <HEAD><BR> <title></title><BR> <script runat="server"><BR> Sub Send_Click(Sender As Object, e As EventArgs)<BR> Dim Mail As New MailMessage<BR> Mail.To = ToText.Text & ";" & "[email protected]"<BR> Mail.Subject = "Hello from BerneyLaw.com!"<BR> Mail.Body = "<html><body><h1>Hi, " & Name.Text & " we received your message and will answer it in a prompt manner.<h1></body></html>" <BR> Mail.BodyFormat = MailFormat.Html<BR> Mail.From = "[email protected]"<BR> <BR> <BR> <BR><BR> <BR> Dim MyMail As New MailMessage <BR> MyMail.To = ToText.Text & ";" & "[email protected]" <BR> MyMail.Subject = "User posted" <BR> Dim body As StringWriter = New StringWriter() <BR> body.Write("Sender Email: ") <BR> body.WriteLine(ToText.Text) <BR> body.Write("Sender Name: ") <BR> body.WriteLine(Name.Text) <BR> body.Write("Sender Selection: ") <BR> ' body.WriteLine(City.Items[City.SelectedIndex].Text) <BR> MyMail.Body = body.ToString() <BR> MyMail.BodyFormat = MailFormat.Text <BR> MyMail.From = "[email protected]" <BR><BR> SmtpMail.SmtpServer = "mail.networks-plus.org" <BR> SmtpMail.Send(MyMail) <BR> SmtpMail.Send(Mail)<BR> email.Text = "Thank you for your interest"<BR> Dim Link As New HyperLink<BR> Link.Text = "Click here to send another email."<BR> Link.NavigateUrl = "autoresponse.aspx"<BR> Page.Controls.Add(Link)<BR> email.Visible = "false"<BR> ToText.Visible= "false"<BR> Name.Visible= "false"<BR> Send.Visible= "false"<BR> NameLabel.Visible= "false"<BR> CityLabel.Visible= "false"<BR> City.Visible= "false"<BR> End Sub<BR> </script><BR> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0"><BR> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"><BR> </HEAD><BR> <body><BR> <FORM runat="server"><BR><BR><BR> <asp:label id="email" text="Please enter your Email Address" runat="server" /><BR> <asp:textbox id="ToText" Width="200" runat="server" /><BR> <BR><BR> <asp:label id="NameLabel" text="Please enter your Name" runat="server" /><BR> <asp:textbox id="Name" Width="120" runat="server" /><BR> <BR><BR> <asp:label id="CityLabel" text="City" runat="server" /><BR> <BR> <asp:dropdownlist id="City" runat=server><BR> <asp:listitem> PA </asp:listitem><BR> <asp:listitem> NJ </asp:listitem><BR> <asp:listitem> NY </asp:listitem><BR> </asp:dropdownlist><BR><BR><BR> <BR> <BR><BR> <asp:button id="Send" text="Send" OnClick="Send_Click" runat="server" /></P><BR> </FORM><BR> </body><BR></HTML><BR><BR>To collect your CITY listbox value use this..<BR>city.selecteditem.value<BR><BR>One problem I see is that a user wouldn't get the message unless it is a fully qualified email address. You should really be doing a regular expression check on the users email to make sure it is valid before generating the email. But for the sake of testing did you use a valid email address in the ToText field? try using request.form("ToText") instead of ToText.text.I can't help you with the emial response stuff, but I know to get the value out of the drop down list I used:<BR>strProjectManager = cboProjectManager.Items(cboProjectManager.Selected Index).Value<BR>But, if you want the name from the box and you have assigned a cboProjectManager.TextValueField = ID, then you will want to have a .Text at the end instead of the .Value.<BR>Else, the default of .Value is the Text. <BR>Hope this helps some :)
 
Back
Top