App_Code/common2/common/Email.cs

(完整代码) 2KB

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Mail;
namespace RM.Common
{
    class Email
    {
        public bool SendMail(string fromMail, string toMail, string ccMail, string bccMail, string subject, string body, string sendMode)
        {
            string SMTPAccount = System.Configuration.ConfigurationManager.AppSettings["SMTPAccount"];
            string SMTPassword = System.Configuration.ConfigurationManager.AppSettings["SMTPassword"];
            try
            {
                MailMessage myMail = new MailMessage();
                myMail.From = fromMail;
                myMail.To = fromMail;
                myMail.Cc = ccMail;
                myMail.Bcc = bccMail;
                myMail.Subject = subject;
                myMail.Body = body;
                myMail.BodyFormat = sendMode == "0" ? MailFormat.Text : MailFormat.Html;

                ////附件
                //string ServerFileName = "";
                //if (this.upfile.PostedFile.ContentLength != 0)
                //{
                //    string upFileName = this.upfile.PostedFile.FileName;
                //    string[] strTemp = upFileName.Split('.');
                //    string upFileExp = strTemp[strTemp.Length - 1].ToString();
                //    ServerFileName = Server.MapPath(DateTime.Now.ToString("yyyyMMddhhmmss") + "." + upFileExp);
                //    this.upfile.PostedFile.SaveAs(ServerFileName);
                //    myMail.Attachments.Add(new MailAttachment(ServerFileName));
                //}


                myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
                myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", SMTPAccount); //发送方邮件帐户
                myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", SMTPassword); //发送方邮件密码

                SmtpMail.SmtpServer = "smtp." + fromMail.Substring(fromMail.IndexOf("@") + 1);
                SmtpMail.Send(myMail);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public void SendMail()
        {
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。