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("from@site.com","Nameofsendingperson");message.From = @”fromAddress”;//here you can set address
message.To.Add("mailto:to@site.com%22%29;//");//message.Subject = "Sending email with ssl";
message.CC.Add("cc@site.com");//ccing the same email to other email addressmessage.Bcc.Add(new MailAddress("bcc@site.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 values
System.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 SSL
mailClient.EnableSSL=true;
mailClient.Send(message);
How can we manage this layer?
ReplyDelete