Click here to Skip to main content
15,889,900 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi frnds!!!


i create application for send mail, before send mail i check email Id and password menace test connection.

if email Id and password combination is not match then give message before send mail.


Plz Help!!!!
Posted

The "built-in" SmtpClinet has no means to log in before sending mail. The smtp protocol itself supports several authentication methods. The one where you can provide password is called AUTH. See this article about some scenarios: http://www.samlogic.net/articles/smtp-commands-reference-auth.htm[^]. As you can see, there are some options, but the protocol itself is not complicated, it i not so hard to implement it with TcpClient. You can even make use of the original SmtpClient source, or look for other implementations on the web.
 
Share this answer
 
Hi
you might want to use this:
C#
//This is the code to send an email message from a console application in C#


MailMessage Email = new MailMessage();

Console.WriteLine("Sender:");
MailAddress Sender = new MailAddress(Console.ReadLine());
Email.From = Sender; // Set the sender of the email message

Console.WriteLine("To:");
Email.To.Add(Console.ReadLine()); // Email address which receives the email

Console.WriteLine("Subject:");
Email.Subject = Console.ReadLine(); // Add emailmessage subject

Console.WriteLine("Text:");
Email.Body = Console.ReadLine(); // email message text

Console.WriteLine("SMTP server:");
string ServerName = Console.ReadLine();//Get the SMTP server address
Console.WriteLine("Port:");
string Port = Console.ReadLine();//Get the port which is used by the SMTP server

SmtpClient MailClient = new SmtpClient(ServerName, int.Parse(Port)); //Create object for SMTP server connection, but no login yet

Console.WriteLine("Username:");
string UserName = Console.ReadLine();//Getting username for login on SMTP server
Console.WriteLine("Password:");
string Password = Console.ReadLine();//Getting password for SMTP login
System.Net.NetworkCredential Credentials = new System.Net.NetworkCredential(UserName, Password);//Create credentials object for login at smtp server

MailClient.Credentials = Credentials; //Add credentials to object for smtp server creation

MailClient.Send(Email); // Send email message. If login at the SMTP server was not possible an exception will be raised at this point.


cheers,
Marco Alessandro Bertschi
 
Share this answer
 
Hii Friend

please improve your question that can help us to help you.
what you actually want to do with smtp???
 
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