net SMTP发送Email邮件且可带附件示例
来源:诚信在线    发布时间:2017-07-06 23:44:14

  }

  const string subject = "Job Recommendation";

  Host = ConfigurationManager.AppSettings["SmtpServer"].ToString(),

  email.Dispose();

  UseDefaultCredentials = false,

  var smtp = new SmtpClient

  inline.ContentType.Name = Path.GetFileName(attachmentPath);

  EnableSsl = true,

  DeliveryMethod = SmtpDeliveryMethod.Network,

  {

  Credentials = new NetworkCredential(fromAddress, fromPassword)

  letter.ContentType.MediaType = FileUploadLetter.PostedFile.ContentType;

  //inline.ContentId = "一";

  DeliveryMethod = SmtpDeliveryMethod.Network,

  Host = "smtp.gmail.com",

  var fromAddress = ConfigurationManager.AppSettings["EmailAddress"];

  //inline.ContentId = "一";

  smtp.Send(email);

  Port = 587,

  using (var message = new MailMessage(fromAddress, toAddress, subject, HttpUtility.HtmlEncode(emailbody)))

  MailMessage email=new MailMessage(fromAddress, "");

  };

  var fromAddress = "";

  //Email Address

  email.Subject = "INLINE attachment TEST";

  inline.ContentDisposition.Inline = true;

  复制代码 代码以下:

  //EmialPWD

  UseDefaultCredentials = false,

  inline.ContentDisposition.DispositionType = DispositionTypeNames.Inline;

  UseDefaultCredentials = false,

  };

  //Credentials = new NetworkCredential(fromAddress, fromPassword)

  email.Attachments.Add(inline);

  string attachmentPath = "C:\\3.jpeg";

  //inline.ContentType.MediaType = "image/png";

  //假如指望经过匿名邮件发送 则

  Host = "serverName",

  DeliveryMethod = SmtpDeliveryMethod.Network,

  你能够感兴趣的文章:用Socket发送电子邮件(哄骗必要考证的SMTP服务器)PHP的一个完好SMTP类(办理邮件服务器必要考证时的成绩)smtp邮件发送1例php外经由过程smtp收邮件的类,测试经过php高利用SMTP领邮件的代码Python httplib,smtplib使用方法PHPMailer邮件类应用smtp.163.com发送邮件法子应用SmtpClient发送邮件的办法C#完成SMTP邮件发送顺序实例SMTP客户端已经过身份验证等多种差错解决方案分享

  EnableSsl = true,

  email.IsBodyHtml = true;

  Attachment inline = new Attachment(attachmentPath);

  var smtp = new SmtpClient

  letter.Name = Path.GetFileName(FileUploadLetter.PostedFile.FileName);

  letter.ContentDisposition.DispositionType = DispositionTypeNames.Inline;

  //若是不门路,用Stream

  }

  Credentials = new NetworkCredential(fromAddress, fromPassword)

  {

  letter.ContentType.Name = Path.GetFileName(FileUploadLetter.PostedFile.FileName);

  Port = int.Parse(ConfigurationManager.AppSettings["SmtpPort"]),

  {

  email.Body = "test";

  smtp.Send(message);

  EnableSsl = false,

  Port = 25, //匿名发送端口

  };

  string fromPassword = "yj1989120";

  letter.ContentDisposition.Inline = true;

  public static void sendEmail(string toAddress, string emailbody)

  {

  Attachment letter = new Attachment(FileUploadLetter.FileContent, FileUploadLetter.PostedFile.ContentType);

  const string subject = "CV";

  {

  string fromPassword = ConfigurationManager.AppSettings["EmailPassword"].ToString();

  var smtp = new SmtpClient


诚信在线 除注明原创以外,其余均来自互联网以及微信朋友圈,如有侵权请联系站长立即删除!
文章地址:http://www.my517517.com/MS/20170706432.html



上一篇:推荐4个原生javascript常用的函数 下一篇:aspnet 支持多语言站点的实现方法