private static void SendEmail(MandrillApi api, SendInfo info, string subj, string content)
        {
            LogManager.GetLogger(typeof(EmailWorker)).Info("Sending email to:" + info.UserEmail);

            var _task = api.SendMessageTemplate(
                new SendMessageTemplateRequest(new EmailMessage
                {
                    To = new[] { new EmailAddress(info.UserEmail) },
                    FromEmail = "*****@*****.**",
                    Subject = subj,
                    TrackClicks = false,
                    TrackOpens = false
                },
                    MANDRILL_TEMPLATE,
                    new[]
                    {
                        new TemplateContent
                        {
                            Name = "main",
                            Content = content
                        }
                    }));
        }
        public ActionResult SendInvitation(InvitationModel model)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand("insert into emailtofriends(name, email, message) values (@name, @email, @message)", connection);
                command.Parameters.AddWithValue("name", model.Name);
                command.Parameters.AddWithValue("email", model.Email);
                command.Parameters.AddWithValue("message", model.Message);

                try
                {
                    command.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    // do what?

                }
                finally
                {
                    connection.Close();
                }

                //Send mandril message
                try
                {
                    MandrillApi api = new MandrillApi(ProjectConfiguration.MandrillApiKey);
                    var emailMessage = new EmailMessage()
                    {
                        To = new List<EmailAddress>() { new EmailAddress(model.Email, "Invited") },
                        FromEmail = ProjectConfiguration.FromEmail,
                        FromName = ProjectConfiguration.FromName,
                        Subject = string.Format(ProjectConfiguration.InvitationEmailSubject, model.Name),
                        Merge = true,
                        MergeLanguage = "mailchimp"
                    };

                    emailMessage.AddGlobalVariable("invitername", model.Name);
                    emailMessage.AddGlobalVariable("invitermessage", model.Message.Replace("\n", "<br />"));

                    var request = new SendMessageTemplateRequest(emailMessage, "invitation", null);
                    var result = api.SendMessageTemplate(request);
                }
                catch (Exception ex)
                {
                    // do what?
                }

                return new EmptyResult();
            }
        }