+ Reply to Thread
Results 1 to 2 of 2

Thread: how to send mail in C# ?

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    35

    how to send mail in C# ?

    i am developing an application that require sending mails , i need the basic concept or function .

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    40
    here is how to send mails in c# :

    Code:
    using System.Net;
    using System.Net.Mail;
    
    SmtpClient client = new SmtpClient("smtp.mail.com"); // you must get your server`s smtp values
    client.Credentials = new NetworkCredential("me@mail.com", "password");
    MailMessage message = new MailMessage();
    message.From = new MailAddress("Your Name", "me@mail.com");
    message.To.Add("touser@mail.com");
    message.Subject = "subject";
    message.Body = "message contents";
    message.Attachments.Add(new Attachment(@"file.txt")); // you can send small attachments but try no more than 5 mbs
    client.Send(message);

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts