Пример #1
0
        public Boolean SendContact(string name, string email, string subject, string messagetxt)
        {
            try
            {
                String       Subject       = "Portfolio Contact";
                String       FilePath      = AppDomain.CurrentDomain.BaseDirectory + "EmailTemplates\\contact.html";
                StreamReader reader        = new StreamReader(FilePath);
                String       TemplateBlock = reader.ReadToEnd();
                reader.Close();
                var mailService = EmailingFactory.Create();

                StringBuilder MainData = new StringBuilder(TemplateBlock);
                MainData.Replace("##name##", name);
                MainData.Replace("##email##", email);
                MainData.Replace("##subject##", subject);
                MainData.Replace("##message##", messagetxt);

                var message = new EmailingMessage
                {
                    Subject = Subject,
                    ToEmail = ConfigurationManager.AppSettings["ToMail"],
                    Body    = MainData.ToString()
                };
                mailService.SendEmail(message);
                MainData = null;

                return(true);
            }
            catch (Exception ex)
            {
            }
            return(false);
        }
Пример #2
0
        private void sendemailAttachment(EmailingMessage Objmail)
        {
            var mailMessage = new MailMessage();

            mailMessage.To.Add(Objmail.ToEmail);
            mailMessage.From       = new MailAddress(EmailConfig.MailAddress);
            mailMessage.Subject    = Objmail.Subject;
            mailMessage.IsBodyHtml = true;
            mailMessage.Body       = Objmail.Body;
            if (Objmail.Attachment != null)
            {
                System.Net.Mail.Attachment attachment;
                attachment = new System.Net.Mail.Attachment(Objmail.Attachment);
                mailMessage.Attachments.Add(attachment);
            }

            var mailClient = new SmtpClient(EmailConfig.SmtpServer);
            int iPort;

            if (int.TryParse(EmailConfig.SmtpServerPort, out iPort))
            {
                mailClient.Port = iPort;
            }
            mailClient.Credentials = new NetworkCredential(EmailConfig.ContestSMTPServerAuthUserName,
                                                           EmailConfig.ContestSMTPServerAuthPassword);
            mailClient.EnableSsl      = true;
            mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
            mailClient.Send(mailMessage);

            Thread.Sleep(900);
        }
Пример #3
0
        private void sendEmail(EmailingMessage mail)
        {
            try
            {
                var mailMessage = new MailMessage();
                mailMessage.To.Add(mail.ToEmail);
                mailMessage.From       = new MailAddress(EmailConfig.MailAddress);
                mailMessage.Subject    = mail.Subject;
                mailMessage.IsBodyHtml = true;
                mailMessage.Body       = mail.Body;

                var mailClient = new SmtpClient(EmailConfig.SmtpServer);
                int iPort;
                if (int.TryParse(EmailConfig.SmtpServerPort, out iPort))
                {
                    mailClient.Port = iPort;
                }
                mailClient.Credentials = new NetworkCredential(EmailConfig.ContestSMTPServerAuthUserName,
                                                               EmailConfig.ContestSMTPServerAuthPassword);
                mailClient.EnableSsl      = true;
                mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                mailClient.Send(mailMessage);

                Thread.Sleep(900);
            }
            catch (SmtpException ex)
            {
            }
        }
Пример #4
0
        public void SendEmailAttachment(EmailingMessage Objmail)
        {
            Thread thread = new Thread(x => sendemailAttachment(Objmail));

            thread.Start(Objmail);
        }
Пример #5
0
        /// <summary>
        /// Sends the given message
        /// </summary>
        public void SendEmail(EmailingMessage mail)
        {
            Thread thread = new Thread(x => sendEmail(mail));

            thread.Start(mail);
        }