.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

The specified string is not in the form required for an e-mail address

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :.NET Framework
I have searched and searched and searched for an answer to this problem...

I have been using the System.Net.Mail namespace for quite a while to send emails from my websites. A problem occurs though on certain (VALID) email addresses. For example, when the name field of the email address has a dot (.) in it (example: my.name@email.com), an exception is raised when this address is added to the TO property of the MailAdddress object. It seems the dot between my and name causes the exception.

Please note that these are valid email addresses, but the MailAddress object considers them to be invalid.

Any suggestions/workarounds?

Error Message: The specified string is not in the form required for an e-mail address.
Stack Trace: at System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset, String& displayName)
at System.Net.Mail.MailAddress.ParseValue(String address)
at System.Net.Mail.MailAddress..ctor(String address, String displayName, Encoding displayNameEncoding)
at System.Net.Mail.MailAddress..ctor(String address, String displayName)

View Complete Post

More Related Resource Links

error in MVC2 on empty string form fields which are required: "This property cannot be set to a null

In model I have:[DisplayName("ISBN")] [Required(ErrorMessage = "ISBN is required.")] [StringLength(50, ErrorMessage = "ISBN book must have max {1} chars.")] [DisplayFormat(ConvertEmptyStringToNull = false)] public string isbn { get; set; }But when I submit form with empty field ISBN I have an error - ConstraintException: This property cannot be set to a null value.I have find that other people have the same problem and they say that debbugger in VS2010 works wrong - yes ?http://p2p.wrox.com/book-professional-asp-net-mvc-2/79788-constraintexception-unhandled-user-code.html#post259245http://efreedom.com/Question/1-3129080/Server-Side-Validation-REQUIRED-String-Property-MVC2-Entity-Framework-Workhttp://mvcmusicstore.codeplex.com/workitem/6604

How to read a column of a sharepoint list to a text string field of infopath form?

My infopath form used to read these email addresses from a web service and web.config file. Now i would like to get these user email addresses from a contact list in a sharepoint server. I am trying to do this without writing any codes. Here is what i have done so far: 1. Adding a new "data connection to receive data from SharePoint library or List" where i selected Email Address column of the contact list. 2. I added a new Text Field and define a new rule with "Query using a data connection" defined above. When i try to access the newly created Text field above it always return empty as if the Query attached to it did not executed at all. What did i do wrong? Is there a better way? Thank you in advance for your help.

Javascript required to get a pop up window from new form.

Hello Team, Any help regarding this would be helpful. I have a new form. In that form when i go to the first field...it should open up a pop up window which would have a note in that. How is this possible. I think through javascript this can be possible. So please help me. Thanks in advance.

asp mail form and calculation

Hi All,I have never used asp before and the owner of a site I am working on requires that everything is done in asp. I have a very simple working version in php. Any help I can get would be great, even if I were to be pointed in the right direction.Code:<?php$to = "email@email.com";$subject = "Email from Web Site";$email = $_POST['email'];$jugs= $_POST['txtJugs'];$coolers= $_POST['txtCoolers'];$spent = ($jugs*6 + $coolers*10)*12;$savings = ($spent*30)/100;$msg = "Email: ".$email."\n Jugs: ".$jugs."\n Coolers: ".$coolers."\n Spent: ".$spent."\n Savings: ".$savings;$extra = "From:$email\r\nReply-To:$email\r\n";mail($to,$subject,$msg,$extra);print "We've calculated that you spend approximately $".$spent." annually on drinking water. <b>Quench can save you approximately $".$savings."</b>. Please <a href='../contactus/index.htm'>contact us</a> for more information.";?>

Best Way to Store Users Mail Address

I have some webforms and the main page grabs the users email address when they login and a UserID.  It's not uncommon for the user to keep the web page open all day.  Is it good practice to store the email address and ID as a session variable and up the timeout to say 10 hours?  Or is there a better way?  My concern is A) Session variables timing out before the user login timesout B) Doing this incorrectly. Thanks!

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?

How to send form result to e-mail from aspx page ?

Hello , I'm stuck with this problem. I have aspx page , (.net 4 , web form ) on this page I have 3 text fields, 3 radio buttons groups, and 6 checkboxes, and button ( submit) . I'm trying to send data to e-mail using button event. The problem which I found that CheckBoxes giving boolean, I want transfer it to Yes or Not. Radio button giving boolean or integer as well. And another problem, I want to send only part which has been answered. empty ( NULL ) field should be ignored. If you can point me in right direction could be cool. What the best way for this? Thank you!

SharePoint Dataview Insert New Mode - Defaulting a Required Column to a Query String Parameter Valu

I've got a SharePoint DataView with an insert button. there is a required lookup column I want to default to the value of Querystring Value during new mode.  Can I do this in the generated code below? I tried replacing @ApplicantId with @QSApplicantID.. and  tried string(@QSApplicantID) too.. no luck gave me an error: The data source control failed to execute the insert command. Could it be that QSApplicantID (which I've used in my DataView Datasource filter with no problem) is not available during the insert? I think I can do what I want in Javascript but was hoping I could instead right in the XSL markup. *my query string parameter**     ParameterBinding Name="QSApplicantID" Location="QueryString(ID)" DefaultValue="2222222"/ **the new form** SharePoint:FormField runat="server" id="ff4{$Pos}" ControlMode="New" FieldName="ApplicantId" __designer:bind="{ddwrt:DataBind('i',concat('ff4',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@ApplicantId')}" / **the link** a href="javascript: {ddwrt:GenFireServerEvent('__cancel;dvt_1_form_insertmode={1}')}">Insert</a Thanks for any help or information!

Setting SharePoint 2010 Form Fields Using Query String Variables


Hi All,

I have a requirement to populate sharepoint form field value with query string while uploading document to document library.

While uploading the document to document library, I want to populate claim number available from query string in a pop up page i.e in my case EditForm.aspx, Located at http://servername:port/sitename/documentlibraryname/forms/EditForm.aspx.

Additional Information:

  • Created document library and added custom columns like claim number etc..
  • Created a view to filter uploaded documents as per claim number.

Server Details:

  • Windows Server 2008 R2
  • SharePoint 2010
  • SQL Server 2008 R2

I have written javascript for the same, but not sure where exactly to add the code in EditForm.aspx page.

Any help on this would be greatly appreciated.

Thanking you in advacne.



converting a hex string to an IP address


i have no idea which forum to post this to, thought i would start here.  i have exported log files from TMG firewall and brought them into sql2008r2.  i have a view that shows me the logtime, ClientIP, and username fields.  So far so good.  The problem is that the IP address field looks like this:  0A370D16 - which, if adjusted, would be 0a.37.0d.16 =  The field is a string - how can i manipulate the select statement to make it look like an ip address (select blahblah as SourceIP from...)?



Sending information in e-mail from a fillable form


I have created a page for filling information, when anyone fills out the form, the information gets e-mailed to all the recipient's e-mail addresses that are mentioned in the code of the page.

I have written the code which is working fine but when i fill out the information in the form, the information is sent to all the 3 e-mail addresses i mentioned in the code, but all 3 recipients of this information can see other recipient's name and address in the "TO " field of their mailbox.

Is it possible to hide other recipients and only show the e-mail address which will be specific to that recipient ?

Here's my code:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
using System.Collections.Generic;
using System.Net;

namespace NopSolutions.NopCommerce.Web

    public partial class Careers : BasePage
        protected static readonly MailAddress from = new MailAddress(MessageManager.AdminEmailAddress, MessageManager.AdminEmailDisplayName);
        protected static readonly List<Ma

System.Net.Mail ignores Sender address when delivery method is SpecifiedPickupDirectory


Has anybody else had an issue with the sender address not being used as the return-path/bounce address when using system.net.mail to send email with a different address for the return-path/sender and the from address and using the SpecifiedPickupDirectory delivery method? This issue is particularly important when you need to send mail from a "user" address, but want bounce backs to come to a different address so they can be processed.

Using the code below, I think you can reproduce the issue.

Imports System.Net.Mail
Partial Class emailtest
    Inherits System.Web.UI.Page

  Protected Sub test_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles test.Click

    ' Build Message
    Dim mail As New MailMessage
    mail.From = New MailAddress("from@domain.com")
    mail.Sender = New MailAddress("sender@domain.com")
    mail.Subject = "Test Subject"
    mail.Body = "Test Body"

    ' Drop in Pickup Directory
    Dim smtpPK As New SmtpClient
    smtpPK.DeliveryMethod = SmtpDeliveryMethod.Sp

InfoPath error: One or more required custom controls in this form cannot be created


I have an InfoPath 2007 form published to a form library in MOSS 2007.  This form opens in InfoPath and is not browser-enabled.

The form suddenly stopped working for me and 1 other user.  I'm a farm admin and the user only has contributor rights on the form library (and site and subsite).  Everyone else with appropriate permissions can access existing forms that use the template and can create new forms using the template.

When either one of us tries to open the form, we get:

InfoPath cannot open the following file: http://site/subsite/formlibrary/filename.xml?OpenIn=PreferClient&NoRedirect=true&XmlLocation=/subsite/formlibrary/filename.xml.
One or more required custom controls in this form cannot be created.

No errors in the web front end event log or SharePoint log files.  No errors in my client PC's event log.

I've tried the following without success:

Opening the template and publishing it to a new list. 
Published the template to a new content type on this list and a new list. 
Dumped IE cache and reset IE settings.
Rebooted the computer.
Checked permissions on the list to make sure they were correct.

Last change made to the farm:

I performed the work around change to the web

Intigrate E-mail part with my infopath form

Hi I am using info path 2010 and I have the scenario that once a job seeker fill the form and submit to sharepoint document library after that when admin open it and check it he/she can directly send an Email from that I have the code but I want to use the templates so if you have any idea please help me 

Intigrate E-mail part with my infopath form

Hi I am using info path 2010 and I have the scenario that once a job seeker fill the form and submit to sharepoint document library after that when admin open it and check it he/she can directly send an Email from that I have the code but I want to use the templates so if you have any idea please help me 

RegEx: converting email address to mailto link in a string using VB



i have tried various ways to accomplish this, but to no avail.  I don't know how to generate the replacement text (mailto link) so I just used a bunch of x's until I can figure it out.  Here is what I have (which currently not replacing emails in string):

Here is my Code behind:

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load


            Me.lblText.Text = DAL.PortLog.PortLogs.PortLogToHTML(Me.TransitID)
        End Sub

Here is the called function to replace email addresses:

    Public Shared Function ConvertEmailToMailToLinks(ByVal textToConvert As String) As String

        Dim pattern As String = "\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b"
        Dim input As String = textToconvert
        Dim replacement As String = "xxxxxxxxxXXXXxxxxx"  'test
        Dim rgx As New Regex(pattern)
        Dim result As String = rgx.Replace(input, replacement)

        Return result

    End Function

Here is the DAL code:

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