Question : How to implement Email Sender using .Net C# Windows services

I need to implement .net windows service which will look in to the database table and send the email to all the new email address excpet the one where its already sent email before

I am using visual studio 2008 standard edition which dont have windows service template installed
I am using c# as a language
Any example or sample code will really help

Thanks

Answer : How to implement Email Sender using .Net C# Windows services

1 - Make sure that in your "emails table" you have a "flag" column that indicate if you have sent an email or not.
2 - Retreive the list of emails that is not already flagged.
3 - Send your email using that kind of code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
MailMessage email = new MailMessage(fromEmail, ToEmail);
email.Subject = subject;
email.CC.Add(toEmailCC);
email.IsBodyHtml = true;
email.Body = body; // your body content in HTML
SmtpClient sMail = new SmtpClient("YourSmtpServer");
sMail.DeliveryMethod = SmtpDeliveryMethod.Network;
sMail.Credentials = new NetworkCredential("YourUserIfNeeded", "YourPasswordIfNeeded");
Attachment item = new Attachment(filename); //if any
email.Attachments.Add(item);
sMail.Send(email);
Random Solutions  
 
programming4us programming4us