Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

I m creating an application that sends the mail, i have made a mail format. I have textbox and a link. I need to validate the textbox that it contains some value on click of the likn.

im stuck at two points

1.I have added a TextBox in the mail. The textbox is coming properly for Browser but for Outlook it is not working

2. I need to validate it that it should contain some data when the user clicks the hyper link

thanks in advance

thanks and regards

VRN

Code Snippet
C#
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
            mail.To.Add("varun.adaptive@gmail.com");
            mail.From = new MailAddress("info.adaptiveprocesses@gmail.com", "Email head", System.Text.Encoding.UTF8);
            mail.Subject = "This mail is send from asp.net application";
            mail.SubjectEncoding = System.Text.Encoding.UTF8;
            mail.Body = "<input type=\"text\" style=\"width:130px\" id=\"txtRemarks\" name=\"txtRemarks\" runat=\"server\" />Please <a href=\"" + ConfigurationManager.AppSettings["Link"].ToString() + "/\"><button type=\"button\">Click</button></a>";
            
            mail.BodyEncoding = System.Text.Encoding.UTF8;
            mail.IsBodyHtml = true;
            mail.Priority = MailPriority.High;
            SmtpClient client = new SmtpClient();
            client.Credentials = new System.Net.NetworkCredential("Email", "Password");
            client.Port = 587;
            client.Host = "smtp.gmail.com";
            client.EnableSsl = true;
            try
            {
                client.Send(mail);
                Page.RegisterStartupScript("UserMsg", "<script>alert('Successfully Send...');</script>");
            }
Posted
Updated 17-Sep-14 1:23am
v3
Comments
Gihan Liyanage 17-Sep-14 7:14am    
Better if you can give a code part
write2varun 17-Sep-14 7:16am    
i used simple mail sending the code with a body that contain HTML tags for a input type and an href for the link but when it is going in outlook it is converting into "[ ]"

Not going to work - the better approach is to have the hyperlink take you to a page which fills in some info (from the hyperlink query string) then get the user to enter data there. Trying to get user input in the body of an email is highly unusual, and
a) AFAIK won't work in Outlook anyway
And
b) Would be seen as spam / phishing activity by most people I suspect.
 
Share this answer
 
Here is the best way to validate an email address client side using jquery validation plugin. Check How-to here

http://jqueryvalidation.org/email-method/[^]
 
Share this answer
 

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



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