Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
C#
string strto = "";
        if (Request.QueryString.Count > 0)
        {
            strto = Request.QueryString.Get("consultantname");
        }

        SqlCommand sqlcommand2 = new SqlCommand("Select B.EmailID from calllog A,HelpdeskConsultedMaster B where A.EmailID=B.consultantname and TicketNumber=" + TicketNo, sqlconn);
        SqlDataReader red = null;
        sqlconn.Open();
        red = sqlcommand2.ExecuteReader();
        StringBuilder todata = new StringBuilder();
        while (red.Read())
        {
            strto = red["EmailID"].ToString();
        }  
        //todata.Append("");
        while (red.Read())
        {
            todata.Append(red["EmailID"].ToString() + ", ");
            if (red["EmailID"] != "")
            {
                todata.Append(red["EmailID"].ToString() + ", ");
            }
            

        }
        sqlconn.Close();


MailAddress from = new MailAddress("arjun.w@intellectbizware.com");
        

        MailAddress to = new MailAddress("strto");

        String[] cs = ccdata.ToString().Split(',');


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

pls let me know the resulation
Posted

I think below is the line which is causing the error.
C#
MailAddress to = new MailAddress("strto");

You need to provide proper email Id, like the one you have provided in
C#
MailAddress from = new MailAddress("arjun.w@intellectbizware.com");
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-Jan-13 3:56am    
Of course. A 5.
—SA
Vani Kulkarni 23-Jan-13 4:35am    
Thanks SA!
Abhinav S 23-Jan-13 3:58am    
Correct. 5.
Vani Kulkarni 23-Jan-13 4:35am    
Thanks Abhinav :)
Arjunwalmiki 23-Jan-13 4:00am    
hello thank you for reply

But i thing you have not see my code proper way i was pass the string strto="";

and use the join and email address need from database. So ple tell me correct solution.
Hi Arjun,
You can throw in a string validation for email using regex!

you can use the pattern:
C#
string emailValidationPattern = "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";


An other option is to use a trick to check it with creating a new MailAddress:
C#
public bool IsValid(string emailaddress)
{
    try
    {
        MailAddress m = new MailAddress(emailaddress);
        return true;
    }
    catch (FormatException)
    {
        return false;
    }
}



Cheers,
Edo
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900