.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Best regex for email body on contact form?

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :.NET Framework
I'm not sure the best way to do a regex for the body section of an email contact form.  I want to use the regex to prevent more than 150 characters from being entered.  I assume this is sufficient, I may need more.  I also want it to help guard against sql injection attacks. The more I think about it the more characters I can think of that should be allowed.  I want to allow punctuation since it's for an email and people should be using full sentences.  These are some other things that make sense to allow: " , ', : , ; , $ , . , ! , ? , - , _ , @ , & , ( , ). They cover situations when someone may put an email address or phone number in the body section for the email.  I also want to allow letters and numbers.    I'm not sure if it's best to allow the characters I mentioned or not allow characters that pose a potential threat.  I think allowing the ones I want is the best way, but I'm not sure.  Can someone please give an example and/or suggestions?  Are there other characters that should be allowed?  I don't have much yet: "^(?i)[a-z0-9\s]{1,150}$"

View Complete Post

More Related Resource Links

Send an Email with User fields data entered in the form


Hi All,

          I have a form which have some user input fields(like textboxes,dropdownlists,textarea etc) fields and a submit button.

on click i need to send email with body contents as all the details entered by user in the form

Can anyone suggest how i should approach to this in sharepoint..

any code examples would be appreciated.


spd2007 - basic form and email


I'm using spd2007 and have created a very basic form to collect data. I've also set it up to send off an email. When I go to the moss2007 site and use the form it appears to be working fine. However, I never receive an email from the workflow. I checked my logs and don't see anything logged about the email not working.

Any suggestions?

Contact Selector - Form tab index is lost after selector resolves names on blur


I'm working with an InfoPath2007 form developed to be filled-out through the browser on a SharePoint 2007 site, and I'm testing using Internet Explorer 7.  It's a straight-forward form, with a number of text fields and two Contact Selector controls.

The issue I'm encountering is with the Contact Selector control, where if the actor only enters a partial name into the text-field and then TABs away from the control the form will perform its auto-postback to look-up and resolve the partial name (showing the name resolution dialog is necessary), and afterward the actor's cursor is focused on the next field in the form.  The actor can type text into the focused field, but any subsequent pressing of the TAB key returns the actor's focus to the browser's ADDRESS bar, which is incorrect as it should proceed to the next field in the form.  I understand that the Contact Selector needs to perform its postback to perform the name resolution (so that there is no way through the InfoPath form designer to disable postbacks for the control), but why does the browser not know how to continue the TAB order of the fields on the form even when a field has focus?

Need Form Application to allow user to review spreadsheets and email

I need an application to allow a user to see a list of documents/spreadsheets in a directory, click a link to the file, have it open, then review it, close it, then from the form choose to accept or deny it, then have it emailed to a recipient contained in a db or list any good ideas how to accomplish this?  maybe a windows form?    

Contact Form Issues

I was hoping someone could assist with this issue I am experiencing.  I have a contact form on my ASP.net page.  Everything works great, but I keep getting blank messages sent to my email address.  It seems to be some sort of SPAM?  Could someone please tell me why this is happening, and what I would need to do to prevent it from happening in the future?

Automatically populating Contact Selector not working in Form Services

Hi,I'm currently working on a form where i wan't to automatically populate a contact selector control with a users manager. I've got the managers userid, called the ResolvePrincipal webservice provided by sharpoint, and set all the values in the contact selector with the correct values. When previewing it works perfectly however when i move the form to Form Services it won't work.I've tried setting it via rules: i.e. on the change of a textbox write the manager values to the contact selector.I've tried setting the default values of the contact selector to fields where i write the manager values.I've tried setting it through code i.e. SelectSingleNode() and SetValue() for each of the fields in the contact selector.All of which work fine in preview mode but will not work in Form Services, UNLESS the contact selector already has a user in it. So if the contact selector is blank it won't work, however as soon as i manually select a user then try using any of the previously mentioned methods of setting the control it works. While using code i get a nullreferenceexception which leads me to think that possibly when theres no user in the control the xml nodes representing the AccountId, DisplayName, AccountType don't exit???? TO throw another spanner in the works, on the very odd occasion it will work in Form Services as expected, after celebrating and trying again it returns

SQL Server Tables and Exchange Web Services sample does not include email body

I've sucessfuly implemented the above, very useful example. However, I cannot work out how to include the Body of the email with the reast of the data. Can anyone shed some light for me? Thanks Robert

Immediate alert email body is truncated intermittently in MOSS 2007

Hi All, I  am facing one issue with Alert. We have one Posts list in one of the Blog where Alert Me generates immediate alert for the users who have subscribed to the Blogs. Whenever any new Post added, edited or deleted they used to get alerts. But in the alert email, the body of the alert which normally contains the Post decsription gets truncated intermittently. Sometimes it is truncated with less than 2048 characters in the Body filed and some times with more than 4098 characters. I found in some articles that the limitation is 2048 characters in one line after whcih the new line is expected , else the text will be truncated. I am not able to find the logic behind this truncation in default sharepoint alert functionality. Could you please give some more insights on this front? Thnaks:)  

Contact Selector Failed in MOSS Workflow Modification Infopath Form

Hi,   In my proof of concept Moss 2007 WF, I tested an Infopath modification form successfully.  Then the contact selector ActiveX control was added but it failed to open using the modification link of the workflow page.  In a different form for the WF initiation, I similarly created two CS controls and it worked there.  A snippet of the MOSS error is below   Object reference not set to an instance of an object.   at Microsoft.Office.InfoPath.Server.Controls.ContactPicker.RenderClientViewDataLeafContent(XPathNavigator context, IRenderContext renderContext, ControlViewData controlViewData, ScriptWriter writer)    at Microsoft.Office.InfoPath.Server.Controls.LeafControl.RenderClientViewDataContent(XPathNavigator context, IRenderContext renderContext, ScriptWriter writer)    at Microsoft.Office.InfoPath.Server.Controls.BaseControl.RenderClientViewData(XPathNavigator context, IRenderContext renderContext, ScriptWriter writer)    at Microsoft.Office.InfoPath.Server.Controls.ContainerControl.RenderClientViewDataContent(XPathNavigator context, IRenderContext renderContext, ScriptWriter writer)    at Microsoft.Office.InfoPath.Server.Controls.BaseControl.RenderClientViewData(XPathNavigator context, IRenderContext renderContext, ScriptWriter writer)    at Microsoft.Office.InfoPath.Server.Controls.CollectionControl.RenderClientViewDataContent(XPathNavigator context, IRenderContext rend

Creating a contact form in asp.net using vb.net (4.0)

I'm using MS VS 2010 and my controls have already been created on the aspx page. i just need a sample code to send  the email to my exchange server in VB.net side of things. thanks in advance.

Calculating email address from AD Username in a form

I have  a change request form that has a requied filed where the user enters a valid username.  In my view for this form I want to display this users email address based their username but I when I look at calculated values the username files is not one that I can do calculations from.  Does anybody know how to do this sort of calculation?

Problems submitting anonymous form via email.

I followd the steps here to configure an InfoPath form to be submitted anonymously. After much trial and error (I'm not a developer, and this was the first time I ever used Visua Studio), I got it working. I now want a second libary that uses pretty much the exact same form, but submits the completed form via email rather than into the document library. I made a copy of my first form template and then changed the submit connection to email. Unfortunately, when I publish this form and try to submit it, I get a error message that "there has been an error processing the form." Any ideas on what might be going on? Here is the working version that submits to the library. Here is the NOT working version.

Regex : Email or Url

hi allI have a text field where user can enter either an URL or an Email address. How can I use a RegularExpressionValidator to validate that user have entered an URL or an Email addressthanks in advanceRegards

Parsing the email body content in a SPEmailEventReceiver class

Hi All, 1. I have an email enabled Sharepoint list which have certain fields like Fname,Lname,Address,Phonenumber   2. Someone will send an email to this list   the email body like this   Fname: Mohammed Lname:Hanif Adress:CA Phonenumber:001234   Now i have to read this body and create a new item in this List where the list fields value will be like this Fname: Mohammed Lname:Hanif Address:CA Phonenumber:001234 Created BY: Email Sender   I can parse the subject and sender to list columns but my problem is to read the content of the Email Body identify the Field value and copy it to corresponding List Fields.   Any help is much appreciated. Regards, Hanif Hanif

create Entity for contact form without database in ASP.NET MVC

I have created in ADO.NET Entity Framework entity for contact form with fields: id, email, subject, message - I don't have that table in database.  And I have an error: Error    Error 3027: No mapping specified for the following EntitySet/AssociationSet - ContactSet.    C:\Users\TEST\Documents\Visual Studio 10\Projects\MvcApplication2\MvcApplication2\Models\CMSModel.edmxScreens:After clicked on this error:

regex match body tag - help



I need regex code to get all content between body tag..

I search on all over the internet but those I find - not working!

example code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
   Example paragraph content
   <br />
  <h1>Header 1</h1>


Please help me.

Email InfoPath form located on secure SharePoint 2007 using Outlook


I have a 2007 InfoPath form that is stored on a secure 2007 SharePoint team site that needs to be emailed to outside users for feedback on a certain subject. The form is opened by a team member (with site access), sent to the reviewer to provide feedback (via Outlook 2007), and then submitted back to the team member for review and submission to the SharePoint site.

The issue I've encountered is that the outside user who receives the form in Outlook as the body of the email cannot enter information in any fields in order to provide feedback. The option to "include the form template with the email" is blocked in my InfoPath form options (I believe because the form location is a secured site). I have tried adding the users to permissions in just the library where the form is published to, but they still cannot enter any information.

Can someone provide me with a solution for this problem?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend