ya k tinstaafi i am the new one to dot net plat form , i dont know exactly what is what thats why i am asking again clearly

  1. Get Email Address From User
  2. Get Subject From User
  3. Get Message From User
  4. Get Destination Address From User
  5. Connect to SMTP Server
  6. Send Mail
  7. ?????
  8. Profit

ya k tinstaafi i am the new one to dot net plat form , i dont know exactly what is what thats why i am asking again clearly

If you don't read the links, which have far more extensive information than a post here would contain, what makes you think that someone posting the code here will help any more?

Anyway, consider the following and see if it helps. It's basically the bare minimum for sending an email through SMTP:

using System;
using System.Net;
using System.Net.Mail;

public class Program
{
    public static void Main()
    {
        try
        {
            SendEmail(
                "smtp.live.com",          // Hotmail's SMTP server
                "foodiddles@hotmail.com", // Note: Bogus login information
                "imapassword",
                true,                     // SSL required for Hotmail
                "foodiddles@hotmail.com", // Bogus sender
                "foo@bar.com",            // Bogus recipient
                "Test Email",
                "This is a test email.");
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }

    public static void SendEmail(
        string server, string userName, string password, bool useSSL, // Server info
        string sender, string recipient, string subject, string body, // Message info
        int timeout = 30)
    {
        using (var mail = new MailMessage())
        {
            var smtp = new SmtpClient(server);

            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.Credentials = new NetworkCredential(userName, password);
            smtp.EnableSsl = useSSL;
            smtp.Timeout = 1000 * timeout;

            mail.From = new MailAddress(sender);
            mail.To.Add(new MailAddress(recipient));
            mail.Subject = subject;
            mail.Body = body;

            smtp.Send(mail);
        }
    }
}
This article has been dead for over six months. Start a new discussion instead.