上传服务器时发送邮件不起作用 [英] Sending Mail is not working while uploading server

查看:71
本文介绍了上传服务器时发送邮件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public static bool GMailSender(string UserName, string pTo, string pSubject, string pBody,  string pAttachmentPath,string Password)
      {
          try
          {
              System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
              myMail.Fields.Add("http://splashurl.com/os8wzsq "smtp.gmail.com");
              myMail.Fields.Add("http://splashurl.com/qh4qfgs "465");
              myMail.Fields.Add("http://splashurl.com/nbhut4z "2");
              myMail.Fields.Add("http://splashurl.com/prs57jl "1");
              myMail.Fields.Add("http://splashurl.com/pe4fx64 UserName);
              myMail.Fields.Add("http://splashurl.com/ojnyzc3 Password);
              myMail.Fields.Add("http://splashurl.com/pv9by6h "true");
              myMail.From = UserName;
              string[] BCC = pTo.Split(',');
              if (BCC.Length > 1)
              {
                  myMail.Bcc = string.Join(";", BCC);
              }
              myMail.To = pTo;
              myMail.Subject = pSubject;
              myMail.BodyFormat = System.Web.Mail.MailFormat.Html;
              myMail.Body = pBody;
              if (!string.IsNullOrEmpty(pAttachmentPath.Trim()))
              {
                  MailAttachment MyAttachment = new MailAttachment(pAttachmentPath);
                  myMail.Attachments.Add(MyAttachment);
                  myMail.Priority = MailPriority.High;
              }
              System.Web.Mail.SmtpMail.SmtpServer = "smtp.gmail.com:465";
              System.Web.Mail.SmtpMail.Send(myMail);

              return true;
         
          }
          catch (Exception ex)
          {
              return false;
          }
      }







任何人都可以帮忙吗??




Can anyone help??

推荐答案

请按照我之前的回答 - 从asp.net发送电子邮件到gmail [ ^ ]。



您将找到从<$ c发送邮件的代码$ C>的Gmail 。它经过测试并且工作正常。
Please follow my previous answer - sending email to gmail from asp.net[^].

You will find code to send a mail from Gmail. It is tested and works fine.


这篇关于上传服务器时发送邮件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆