Beispiel #1
0
        public static void SendEmail(MailMessage mail, object token, EmailEntityType typeToSave)
        {
            try
            {
                SmtpClient smtp = new SmtpClient();
                smtp.EnableSsl = false;
                smtp.Send(mail);
                Console.WriteLine("Completed MessageRecipient.Id:" + token);

                if (null != token)
                {
                    if (EmailEntityType.MessageRecipient == typeToSave)
                    {
                        Guid messageRecipientId         = new Guid(token.ToString());
                        MessageRepository msgRepository = new MessageRepository();
                        Message           msg           = msgRepository.FindByMessageRecipientId(messageRecipientId);
                        msg.SentDate = DateTime.Now;
                        msgRepository.Save(msg);
                    }
                    else if (EmailEntityType.InnerCircle == typeToSave)
                    {
                        Guid innerCircleId = new Guid(token.ToString());
                        InnerCircleRepository icRepository = new InnerCircleRepository();
                        InnerCircle           ic           = icRepository.GetById(innerCircleId);
                        ic.NotificationSentDate = DateTime.Now;
                        icRepository.Save(ic);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error" + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }