Need Email validation source code (C#)

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2005
Posts: 7
Reputation: Prasadd is an unknown quantity at this point 
Solved Threads: 0
Prasadd Prasadd is offline Offline
Newbie Poster

Need Email validation source code (C#)

 
0
  #1
Jul 23rd, 2005
Hi,

I am working on a Desktop application using C# .NET

Looking for some code that does 'email syntax validation' and 'send mail' tasks.
Since it is not a web based application this cannot be done using Web based namespaces etc.


Can anyone please help me out or even suggest sumthing..

Thanx
- Prasadd
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 17
Reputation: cambia is an unknown quantity at this point 
Solved Threads: 3
cambia's Avatar
cambia cambia is offline Offline
Newbie Poster

Re: Need Email validation source code (C#)

 
0
  #2
Jul 28th, 2005
Hi Prasadd,

1) First the email syntax validation.

I have written an article on this at the following link. In short, you can use regular expressions:
Email Validation

2) Send email from a desktop application.

You can use the SmtpMail class just as you would in an ASP.NET application. You just need to add a reference to the System.Web.dll library. If you are using Visual Studio .NET, go to the Solution Explorer and right click 'References' in your project. Choose to Add Reference. Then browse the .NET tab for System.Web.dll and add it. Then the following should work.

  1. System.Web.Mail.SmtpMail.SmtpServer = "your server";
  2. string to = "you@email.com";
  3. string from = "someone@email.com";
  4. string subject = "Email Test";
  5. string body = "Test Body";
  6. Sysetm.Web.Mail.SmtpMail.SmtpServer.Send(to, from subject, body);

Cheers,
Steve
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 17
Reputation: cambia is an unknown quantity at this point 
Solved Threads: 3
cambia's Avatar
cambia cambia is offline Offline
Newbie Poster

Re: Need Email validation source code (C#)

 
0
  #3
Jul 28th, 2005
Oops. The last line should read
  1. System.Web.Mail.SmtpMail.Send(to, from subject, body);

Originally Posted by cambia
  1. System.Web.Mail.SmtpMail.SmtpServer = "your server";
  2. string to = "you@email.com";
  3. string from = "someone@email.com";
  4. string subject = "Email Test";
  5. string body = "Test Body";
  6. Sysetm.Web.Mail.SmtpMail.SmtpServer.Send(to, from subject, body);
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1
Reputation: chirag.3g is an unknown quantity at this point 
Solved Threads: 0
chirag.3g chirag.3g is offline Offline
Newbie Poster

Re: Need Email validation source code (C#)

 
0
  #4
Aug 30th, 2008
Originally Posted by Prasadd View Post
Hi,

I am working on a Desktop application using C# .NET

Looking for some code that does 'email syntax validation' and 'send mail' tasks.
Since it is not a web based application this cannot be done using Web based namespaces etc.


Can anyone please help me out or even suggest sumthing..

Thanx
- Prasadd
hi, Prasadd

Use RegularExpression.RegEx class
here is example for Email validation that i have made try it.

public static bool ValidEmail(string validatingstring, string displaymessage)
{
if (!Regex.Match(validatingstring, @"^[a-zA-Z][a-zA-Z0-9_-]+@[a-zA-Z]+[.]{1}[a-
zA-Z]+$").Success)
{
//Email was incorrect
ErrorMessage(displaymessage);
return false;
}
else
{
return true;
}
}

Regards,
Chirag Shah
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC