3
Reply

Sending mails through C#.net

d kris

d kris

Apr 25 2010 8:18 AM
2.4k

Hi everyone,

There is a code snippet for sending mail via c#.net application....It requires the header file System.Web.Mail...
All I wanted to know is that - is installation of iis a pre requisite for using this particular feature? please lemme know ... Any help would be appreciated... The code is sumthing like this:

 System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); 

     
         System.Net.NetworkCredential cred = new System.Net.NetworkCredential("[email protected]", "password");
         mail.To.Add("[email protected]");
          mail.Subject = "Reminder";


          
             mail.From = new System.Net.Mail.MailAddress("[email protected]", "def");
             mail.IsBodyHtml = true;
             mail.Body = "This is a system generated mesage";
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
             smtp.UseDefaultCredentials = false;
             smtp.EnableSsl = true;
             smtp.Credentials = cred; 
              smtp.Send(mail);

thanx again

Answers (3)