示例#1
0
        public static string SendMail(string mailFrom, string mailSender, string mailTo, string cc, string bcc, string replyTo, MailPriority priority, string subject, MailFormat bodyFormat, Encoding bodyEncoding,
                                      string body, ICollection <MailAttachment> attachments, string smtpServer, string smtpAuthentication, string smtpUsername, string smtpPassword, bool smtpEnableSSL)
        {
            var smtpInfo = new SmtpInfo
            {
                Server         = smtpServer,
                Authentication = smtpAuthentication,
                Username       = smtpUsername,
                Password       = smtpPassword,
                EnableSSL      = smtpEnableSSL,
            };

            var mailInfo = new MailInfo
            {
                From         = mailFrom,
                Sender       = mailSender,
                To           = mailTo,
                CC           = cc,
                BCC          = bcc,
                ReplyTo      = replyTo,
                Priority     = priority,
                BodyEncoding = bodyEncoding,
                BodyFormat   = bodyFormat,
                Body         = body,
                Subject      = subject,
                Attachments  = attachments,
            };

            if (PortalSettings.Current != null && UserController.GetUserByEmail(PortalSettings.Current.PortalId, mailFrom) != null)
            {
                mailInfo.FromName = UserController.GetUserByEmail(PortalSettings.Current.PortalId, mailFrom).DisplayName;
            }

            return(MailProvider.Instance().SendMail(mailInfo, smtpInfo));
        }
示例#2
0
        public static string SendEmail(string fromAddress, string senderAddress, string toAddress, string subject, string body, ICollection <MailAttachment> attachments)
        {
            var mailInfo = new MailInfo
            {
                From         = fromAddress,
                Sender       = senderAddress,
                To           = toAddress,
                Subject      = subject,
                Body         = body,
                Priority     = MailPriority.Normal,
                BodyFormat   = HtmlUtils.IsHtml(body) ? MailFormat.Html : MailFormat.Text,
                BodyEncoding = Encoding.UTF8,
                Attachments  = attachments,
            };

            return(MailProvider.Instance().SendMail(mailInfo));
        }
示例#3
0
        public static void SendEmail(string fromAddress, string senderAddress, string toAddress, string subject, string body)
        {
            if (string.IsNullOrWhiteSpace(Host.SMTPServer) || string.IsNullOrEmpty(fromAddress) || string.IsNullOrEmpty(senderAddress) || string.IsNullOrEmpty(toAddress))
            {
                return;
            }

            var mailInfo = new MailInfo
            {
                From         = fromAddress,
                Sender       = senderAddress,
                To           = toAddress,
                Subject      = subject,
                Body         = body,
                Priority     = MailPriority.Normal,
                BodyFormat   = HtmlUtils.IsHtml(body) ? MailFormat.Html : MailFormat.Text,
                BodyEncoding = Encoding.UTF8,
            };

            MailProvider.Instance().SendMail(mailInfo);
        }