I am creating a website where i want to send email notification of every website activity like Facebook
How can i send automatic emails to logged in user?
To send an email is fairly easy. First you need to import the System.Net.Mail namespace to get access to everything you need. Then you create an instance of an SmtpClient (which you provide with the details regarding the email account that will be sending the email) and a MailMessage instance which holds the subject, message, attachments, etc. Then send it.
You'll find plenty of good tutorials online. Here is one to start you off:
You need to have a service (or an application) running on the server (or which is run on the server as regular intervals) which monitors your data source, and sends the emails.
This code was developed in VB.Net code, you have to convert the code.
Dim mailMsg As MailMessage = New MailMessage Dim smtpClient As SmtpClient = New SmtpClient mailMsg.To.Add("firstname.lastname@example.org") mailMsg.Subject = "Silverlight Project Executed" mailMsg.Body = "Config Mail" mailMsg.Attachments.Add(New Attachment("AttachedFileName")) mailMsg.IsBodyHtml = True mailMsg.From = New MailAddress("email@example.com") smtpClient.Credentials = New NetworkCredential("firstname.lastname@example.org", "pass1234") smtpClient.Host = "smtp.gmail.com" smtpClient.Port = 25 smtpClient.EnableSsl = True smtpClient.Send(mailMsg)