In earlier post i have mentioned that how to send the email using new System.Net.Smtpmail with asp.net 2.0 or higher version. Now lets learn how to send the mail with the secure service layer in the asp.net.
Security is the one of the most important requirement in today’s world as you are doing your business online you have keep secure from other wrong elements. Secure service layer add an
extra layer of security to your web application and sending mail with the SSL with tighten your security for mails. Your emails are more secure then ever and your valuable information will not going to wrong hands.
Here is the code from which we can send the email with the secure service layer. As i have mentioned in earlier post you need to to send email with authentication to use SSL. So you need to write following code. First you need to create message like following..
Then you have to sent message with following code.MailAddress fromAddress = new MailAddress("firstname.lastname@example.org","Nameofsendingperson");message.From = @”fromAddress”;//here you can set addressmessage.To.Add("mailto:email@example.com%22%29;//");//message.Subject = "Sending email with ssl";message.CC.Add("firstname.lastname@example.org");//ccing the same email to other email addressmessage.Bcc.Add(new MailAddress("email@example.com"));//here you can add bcc addressmessage.IsBodyHtml = true;//To determine email body is html or notmessage.Body =@"Plain or HTML Text";
System.Net.Mail.SmtpClient mailClient =new System.Net.Mail.SmtpClient("your smptp","ssl port");//This object stores the authentication valuesSystem.Net.NetworkCredential basicCrenntial =new System.Net.NetworkCredential("username", "password");mailClient.Host = "Host";mailClient.UseDefaultCredentials = false;mailClient.Credentials = basicCrenntial;// You have to add one other properties for SSLmailClient.EnableSSL=true;mailClient.Send(message);