Web Form Email Job Problem

I have a web form that pulls data entered by the user, and then sends out an email to the user and an email group based on the category selected by the user. The groups used for the categories are stored within an XML doc. I'm able to parse the XML doc without a problem. I know this because I assigned the email variable to a label on the page, and I can see the result after the form is submitted.

But when I try to apply that same email address variable from that XML parse into the email job within the code file, I receive the following error:
The specified string is not in the form required for an e-mail address.

I've included my code below. If anyone could let me know what steps I'm missing, that would be great. Thanks.

test.aspx
 

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" CodeFile="test.aspx.vb" Inherits="feedback_test" AutoEventWireup="true" title="Feedback Form - TEST" %>
<asp:content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="server">
<% If Not Page.IsPostBack Then %> <form name="formFeedback" action="" method="post" runat="server">
<asp:ValidationSummary ID="valSummary" runat="server" HeaderText="You must fix the following form entries:" Font-Names="verdana" Font-Size="10pt" Font-Bold="True" /> <br />
<table class="tableborder_black" width="98%" id="Feedback Form">
<tbody>
<tr class="tablecell_black">
<th scope="col" colspan="2">Feedback Form</th>
</tr>
<tr>
<td class="tablecell1" align="right" valign="top">Category</td>
<td class="tablecell3">
<asp:DropDownList id="selectCategory" runat="server">
<asp:ListItem Value="gen" Text="General" Selected="True" />
<asp:ListItem Value="cat1" Text="Category 1" />
<asp:ListItem Value="cat2" Text="Category 2" />
<asp:ListItem Value="cat3" Text="Category 3" />
</asp:DropDownList>
</td>
</tr>

<tr>
<td class="tablecell1" align="right" valign="top">Email Address</td>
<td class="tablecell3"><asp:Textbox id="txtEmailAddress" columns="20" runat="server" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" ControlToValidate="txtEmailAddress" ErrorMessage="Email must be valid (Format: you@domain.com)." ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="tablecell1" align="right" valign="top" style="height: 50px">Comments</td>
<td class="tablecell3" style="height: 50px">
<asp:TextBox ID="txtComments" Columns="40" Rows="4" runat="server" Height="60px" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtComments" ErrorMessage="Must enter comments to complete this form." Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator8" runat="server" ControlToValidate="txtComments" ErrorMessage="Must enter between 5 and 1000 characters." ValidationExpression="^[a-zA-Z-0-9]{5,1000}$" Display="Dynamic"></asp:RegularExpressionValidator>
</td>
</tr>
<tr class="tablecell_black">
<td scope="col" colspan="2" align="center">
<asp:HiddenField ID="hfDateTime" runat="server" />
<input id="btnReset" type="Reset" runat="server">
<asp:Button ID="btnSubmit" Text="Submit" OnClick="SubmitBtn_Click" runat="server" />
</td>
</tr>
</tbody>
</table>
</form>
<br /><br />
<!-- Test variables --> <strong>lblContactsTitle: </strong><asp:label id="lblContactsTitle" runat="server" /><br />
<strong>lblContactsEmail: </strong><asp:label id="lblContactsEmail" runat="server" /><br />
<strong>lblCategory: </strong><asp:label id="lblCategory" runat="server" /><br />
<strong>lblEmailAddress: </strong><asp:label id="lblEmailAddress" runat="server" /><br />
<strong>lblComments: </strong><asp:label id="lblComments" runat="server" /><br />
<% Else %> <asp:label id="lblErrorMsg" runat="server" /><br />
<% End If %> </asp:content>
 
test.aspx.vb
 
Partial Class feedback_test
Inherits System.Web.UI.Page

Dim strSiteDomain As String = "/mysite" Sub SubmitBtn_Click(ByVal Sender As Object, ByVal E As EventArgs)
'Declare form variables Dim category_form As String = selectCategory.SelectedItem.Value
Dim email_form As String = txtEmailAddress.Text
Dim comments_form As String = txtComments.Text

'Assign date variables Dim dtCurrDate As DateTime = DateTime.Now 'Assign current date Dim strDateTimeISO As String = dtCurrDate.ToString("s") 'ISO format hfDateTime.Value = strDateTimeISO 'Assign labels lblCategory.Text = category_form lblEmailAddress.Text = email_form lblComments.Text = comments_form If Page.IsValid Then
Try
'Pull group members by selected category Dim objEmailGroup As Object = False
Dim
strXMLPath_contacts As String, strXSLPath_contacts As String strXMLPath_contacts = strSiteDomain & "/help/docs/xml/contacts.xml" 'xml doc strXSLPath_contacts = strSiteDomain & "/help/docs/xslt/contacts.xsl" 'xsl doc

'Load MainContent XML file internal_links.xml and assign page properties
Dim strContactsTitle As String = Nothing, strContactsEmail As String = Nothing
Dim
contacts_xmld As XmlDocument
Dim contacts_nodelist As XmlNodeList
Dim xml_node As XmlNode
'Create the XML Document contacts_xmld = New XmlDocument()
'Load the Xml file contacts_xmld.Load(MapPath(strSiteDomain & "/help/docs/xml/contacts.xml"))

'Get the list of name nodes contacts_nodelist = contacts_xmld.SelectNodes("/contacts/dept_div[@id = '" & category_form & "']")
'Response.Write(contacts_nodelist) 'TEST

'Loop through the nodes
For Each xml_node In contacts_nodelist 'Pull XML nodes strContactsTitle = xml_node.Item("
title").InnerText
strContactsEmail = xml_node.Item("
email_contacts").InnerText

lblContactsTitle.Text = strContactsTitle
lblContactsEmail.Text = strContactsEmail

Next 'end loop

'Email job to group members
Dim mail_group As New System.Net.Mail.MailMessage(email_form, strContactsEmail, "
Feedback Form", "<font face='arial' size='2'>The following feedback was submitted to your department:<br /><br/ ><strong>Category: </strong>" & category_form & "<br /><strong>Comments: </strong>" & comments_form & "</font>") Dim mail_user As New System.Net.Mail.MailMessage("webmaster@mysite.com", email_form, "Feedback Form", "<font face='arial' size='2'>Thank you for submitting feedback through our feedback form. If requested, someone from our staff will be in contact with you withing 2-3 business days.<br /><br />Webmaster</font>") Response.Write("objEmailGroup = True<br />")

'strContactsEmail
'email_form = user's email address
mail_group.BodyEncoding = System.Text.Encoding.UTF8 mail_group.IsBodyHtml = True mail_user.BodyEncoding = System.Text.Encoding.UTF8 mail_user.IsBodyHtml = True Dim smtpUser As String = "
USERNAME"
Dim smtpPassword As String = "
PASSWORD"
Dim smtpServer As String = "
EMAILSERVERNAME"

Dim smtp As New Net.Mail.SmtpClient()

With smtp
If smtpUser.Length > 0 Then
.Host = smtpServer
.Port = 25
.Credentials = New System.Net.NetworkCredential(smtpUser, smtpPassword)
End If
End With

'Email job to group smtp.Send(mail_group) 'Email job to user for confirmation (if email is not empty) If email_form <> "
" Then
smtp.Send(mail_user)
End If

Catch
lblErrorMsg.Text = "
There was a problem while submitting this form. Please contact the <a href='mailto:webmaster@mysite.com'>Webmaster</a>." End Try
End If
End Sub

End Class
 

KWilliams
0
kwilliams
6/23/2008 7:40:27 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

4 Replies
481 Views

Similar Articles

[PageSpeed] 40

What is in the string strContactsEmail when you create the mail_group MailMessage? If it is a semi-colon delimited list, I think that may be your problem, I think that constructor to MailMessage can take only one email address in a string. If you want more than one create a new MailAddress and use the .Add method to add each of them to the MailMessage.

0
coolhotrod
6/23/2008 9:10:46 PM

Yes, that's exactly it. That variable contains 2 email addresses separated by a semicolon. So could you forward me an example using the code I submitted? I'd like to test it out, but I'm not sure how to proceed. Thanks.


KWilliams
0
kwilliams
6/23/2008 9:17:10 PM

Try this (this is untested, but I think it should work)

 

Dim mail_group As New System.Net.Mail.MailMessage()
mail_group.From = New System.Net.Mail.MailAddress(email_form)
mail_group.Subject = "Feeback Form"
mail_group.Body = "<font face='arial' size='2'>The following feedback was submitted to your department:<br /><br/ ><strong>Category: </strong>" & category_form & "<br /><strong>Comments: </strong>" & comments_form & "</font>"
Dim addresses As String() = strContactsEmail.Split(New Char() {";"})

For Each address As String In addresses
    mail_group.To.Add(New MailAddress(address))
Next
 
0
coolhotrod
6/23/2008 9:29:52 PM

After some research, I just found another easier solution. When I changed the semicolon's to comma's, it worked great. But I'm going to also give your solution a try to see how it works. Thanks so much for your help:)


KWilliams
0
kwilliams
6/23/2008 9:35:20 PM
Reply:

Similar Artilces:

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

For interrupting.web form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form
Web Form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form ! Because of my pool English, if you can't see , I will explain more ! ThanksGambler is the real life I guess you mean when form grows it also grow parent div element. This is normal. If you want div to stay fixed size and rather clip the form and maybe show a scrollbar, look at overflow property in CSS.Thanks------------------------------------------------------------This posting is provided "AS IS" with no warranties, and confers no ...

Include web form inside web form
I tried to include an aspx file in a asp.net web form. However, all the web controls (textbox, button) in the included page are not displayed when called. <Form id="Form1" method="post" runat="server"> <%   Response.writeFile("subPage.aspx"); %> <asp:button id="btnPrev" runat="server" text="Previous"></asp:button> </Form> There are some <asp:textbox> controls in the subPage.aspx file, the file itself works fine, but when it is included in the main page, all the controls are not displayed. Please assist. Thanks   u should u...

calling a web form from another web form
I would like to know what is the best way to open a web form from another web form. I would like to call it from a button control. Thanks Well, if I've grasped your question right, there are many methods to do that: 1)Response.Redirect > To navigate to another page from code and is equal to clicking a hyperlink. I suggest this as I think it's closer to your question. 2)Server.Transfer > This ends the current web form and begins a new web form. It's usable when you want to pass some variables i.e (Label1.Text) to the next immediate page. It's not safe though and not used to send p...

How to fire events in other web form from other web form ?
Suppose that I have A and B web form. I want to trigger B web form's Page_Load event from A web form. How can I do that ? Thanks in advanced WilbertWilbert Bujn Create a public method in B that call the load method : public void Load(object sender, System.EventArgs e) { Page_Load(sender, e) ; } In the page_load of A, instanciate a B object and then call the function B myB = new B() ; myB.Load() ; Quicky Thank you quicky, it works fine. WilbertWilbert Bujn...

Web Form embedded in another Web Form
Hi,  I have programmed a Web Form which acts like a scientific calculator. I would like to embedd this calculator in the upper left hand corner of another accounting Web Form. I don't want to host the calculator on the same server as the accounting page. I.e. I want them to have distinct URLs. Classically, I would do this using frames, but is there a better way using ASP? Is there some sort of Panel which can display the webpage at a specific URL which I can just drag onto my accounting Web Form? Thanks,  P1000   Frames are the only way to embed a webform inside ano...

Web Form vs. Web Content Form
If you don't mind, I would like to know what is the difference between those two items, when I go to add a new item I see both of those and I don't know what the difference is.  A content form is for use with a masterpage. A web form is a standalone web page. If you select web content form, you will then have to specify a masterpage for it. and what is a master page used for?  Hi, a master page is used to give a constant look and theme to a site, without having to duplicate code. So basically you can put your header, menu, nav and footer on a master page. Then a...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspxSSNPlease remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

Passing Values from a Web Form to Another Web Form
Hello All! I am trying to pass values from one web form to another web form. I know that there are 3 ways of doing this: queryString, Server.Transfer and Session. I am using the Server.Transfer method. But I am not able to create, in my 2nd web form, an instance of my 1st web form. My 1st Web form is named CallTrack.aspx and my 2nd is named Export.aspx. What I mean is something like this: Public value as CallTrack. I can't create it in my 2nd web form because when the intellisense is displayed, there's no CallTrack in the options. Thanks!   How about using cross-...

Accessing two web forms in a single web form
  Hi. I am developing a website in VS 2005 with Ajax & SQL Server. I am having 5 forms in my application. 1) Login Form 2) Main form 3) Form "A" 4) Form "B" I need to show the main form after the User login. I need to show all the contents of form A or form B (Ex: Form "A" user or form "B" user) in the Main Page. Can I show a single page having Main Form controls as well as Form "A" and Form "B" controls? I should access all the controls including Form A/B in the Main Page. Thanks ...

Strange output in web form after web form is displayed.
   I have been using a web user control for over a week now with no problems. I am now getting strange output in my web form after my controls display on the page. Below is the strange output. Can anyone tell me what is wrong here? Note I did not include it all because it is quite large.   Request Details Session Id: l5b5vkazucfatba4oliaw1vi Request Type: POST Time of Request: 9/10/2007 4:59:59 PM Status Code: 200 Request Encoding: Unicode (UTF-8) Response Encoding: Unicode (UTF-8) Trace Information Category Message From First(s) F...

Web Form : Block the return button on the web form
Hello, I have a principal form with a list of information. From this form, I go on an edit forms and I want to control what is done on this form. For this, I want to block the button Windows back on my edit form. Somebody can help me ? Thank you for your help.  Jy. set the Session Variable (with your ID or whatever ) in the Principal Form when user click on Edit then put the One Back Button on your edit form and Redirect the page by using the Session variable value.Please Mark as Answred If This Blog has Helped You.RegardsMitesh Darjihttp://www.indianic.comhttp://www.mitatdotnet....

Web resources about - Web Form Email Job Problem - asp.net.web-forms

Is–ought problem - Wikipedia, the free encyclopedia
The is–ought problem in meta-ethics as articulated by Scottish philosopher and historian David Hume (1711–76) is that many writers make claims ...

Corporate Australia's real problem: ancient companies
Our biggest companies are pretty aged, compared to the dynamic corporate giants that power the world's biggest economy.

Dick’s Sporting Goods athleisure problem - Business Insider Deutschland
Dick's Sporting Goods has sold athletic apparel for decades. But now, the retailer faces more competition than ever.

November 2015: Unofficial Problem Bank list declines to 255 Institutions
This is an unofficial list of Problem Banks compiled only from public sources. Here is the unofficial problem bank list for November 2015. Changes ...

Tri-Valley has no problem against Auburn to win 2A title
... form Search 39° Navigation Home Blackhawks Bulls Cubs White Sox Bears Fire Notre Dame Preps More Tickets Shop Watch Tri-Valley has no problem ...

Tesla Unveils ‘Cheap’ $80,000 SUV, As Problems Mount For The Automaker
Tesla unveiled an $80,000 “budget” version of its Tesla Model X SUV Tuesday as the company struggles to sell cars and burns through cash at an ...

This week in the war on workers: Rising federal taxes aren't the problem for the middle class
Turns out, federal taxes on the middle class aren’t so high these days: Note that the figure includes all federal taxes—the income tax rate ...

The 'Design Sprint' Approach To Solving Problems In Your Organization
Innovation is a goal for many organizations, but how do you actually get people in a room, constructively and innovatively solving problems? ...

Family evicted, building deemed unlivable: Landlord cannot fix problems, he was murdered
... A Milwaukee family has been forced to leave their apartment. Their building has been declared unlivable. The landlord was required to fix problems ...

Another Common Core Math Problem Has Parents Baffled
A baffled parent shared a picture of their child's Common Core-style math test.

Resources last updated: 11/30/2015 4:40:29 AM