-3

I would like to send an automated e-mail to my clients on their birthday. Is there a library or a good place to find template code for doing something like this? I've used SMTP in the past, but that was for iOS development. I am looking for something using JS or .NET (or maybe even HTML?) to do this. I am only guessing that it will need to be server-side because it needs to run automatically, pulling birthdays from the database.

Has anyone used certain methods that they have found particularly effective? Thanks

catfood
  • 4,267
  • 5
  • 29
  • 55
Alex Chumbley
  • 754
  • 3
  • 10
  • 14
  • Look at the SmtpClient class. It has what you need. There are endless examples on how to use this class. http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx – squillman Jun 24 '13 at 17:42
  • hopefully this wont apply to you, but just in case, you may want to have a look at this: http://stackoverflow.com/questions/3905734/how-to-send-100-000-emails-weekly – Daniel Jun 24 '13 at 17:51
  • Did you Google this before asking? Googling ".NET sending email" returns several articles about how to send email through .NET APIs. Research before you ask a question. – Karl Anderson Jun 24 '13 at 18:01

1 Answers1

1

Below is a simple example of sending mail with .NET'S SMTPClient

using (System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage())
 {

  mailMessage.To.Add(new MailAddress(toAddress ));

  mailMessage.From = new MailAddress(fromAddress, nameToAppearFrom);

  mailMessage.Subject = subject;
  mailMessage.Body = messageText;
  mailMessage.IsBodyHtml = true;

  SmtpClient smtpClient = new SmtpClient();
  smtpClient.EnableSsl = true;

  smtpClient.Send(mailMessage);
}

In order to use this you would also need Using System.Net.Mail ; in your code file and in your web config you would need

  <system.net>
    <mailSettings>
      <smtp from="from address">
        <network host="yourt mail server" defaultCredentials="false" port="port#" userName="username" password="password"/>
      </smtp>
    </mailSettings>
  </system.net>

Alternatively depending on the database engine you are using you could also send mail from the database, this could be in the form of a daily job that gets all people with birthdays and then calls a mail function/stored procedure

Kevin Kunderman
  • 2,036
  • 1
  • 19
  • 30