Esempio n. 1
0
 public static void Send(string Recipient, string Sender, string Subject, string Body)
 {
     Send(SmtpConfig.Create().SmtpSetting.Server, Sender, Recipient, Subject, Body, true, Encoding.UTF8, true, null);
 }
Esempio n. 2
0
 public static SmtpConfig Create()
 {
     if (_smtpConfig == null)
     {
         _smtpConfig = new SmtpConfig();
     }
     return _smtpConfig;
 }
Esempio n. 3
0
 public static void Send(string recipient, string subject, string body)
 {
     Send(SmtpConfig.Create().SmtpSetting.Server, SmtpConfig.Create().SmtpSetting.Sender, recipient, subject, body, true, Encoding.Default, true, null);
 }
Esempio n. 4
0
        public static void Send(string server, string sender, string recipient, string subject, string body, bool isBodyHtml, Encoding encoding, bool isAuthentication, params string[] files)
        {
            SmtpClient  smtpClient = new SmtpClient(server);
            MailMessage message    = new MailMessage(sender, recipient);

            message.Priority   = MailPriority.High;
            message.IsBodyHtml = isBodyHtml;    //html format

            message.SubjectEncoding = encoding; //encoding
            message.BodyEncoding    = encoding; //encoding

            message.Subject = subject;          //title
            message.Body    = body;             //content

            message.Attachments.Clear();


            if (files != null && files.Length != 0)
            {
                for (int i = 0; i < files.Length; ++i)
                {
                    Attachment attach = new Attachment(files[i]);
                    message.Attachments.Add(attach);
                }
            }

            if (isAuthentication == true)
            {
                smtpClient.Credentials = new NetworkCredential(SmtpConfig.Create().SmtpSetting.User, SmtpConfig.Create().SmtpSetting.Password);
            }
            smtpClient.Send(message);
        }