发送邮件的代码 [英] code for sending mail

查看:62
本文介绍了发送邮件的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写用于在asp.net中使用c#.net生成电子邮件的代码

how to write code for generating email in asp.net with c# .net

推荐答案

您是否读过 this [ ^ ]在这里发布你的问题之前?



在ASP.Net 2.0中发送电子邮件 [< a href =http://www.codeproject.com/Articles/12511/Send-Email-in-ASP-Net-2-0-Feed-back-Formtarget =_ blanktitle =New Window> ^ ]

发送电子邮件来自ASP.Net 4 - C#示例代码 [ ^ ]



Google中有很多例子。相信我。 Checkit [ ^ ]
Did you read this[^] before posting your question here?

Send Email in ASP.Net 2.0[^]
Sending email from ASP.Net 4 – C# sample code[^]

there are plenty of examples in Google.Dont believe me.Checkit[^]


protected void SendMail()
  {
      // Gmail Address from where you send the mail
      var fromAddress = "google@gmail.com";
      // any address where the email will be sending
      var toAddress = "info@gmail.com";
      //Password of your gmail address
      const string fromPassword = "123456789";
      // Passing the values and make a email formate to display
      string subject = TextBox3.Text.ToString();
      string body = "From: " + txtname.Text + "\n";
      body += "Email: " + txtemail.Text + "\n";
      body += "Mobile: " + txtsubject.Text + "\n";
      body += "Message: \n" + txtmsg.Text + "\n";
      // smtp settings
      var smtp = new System.Net.Mail.SmtpClient();
      {
          smtp.Host = "smtp.gmail.com";
          smtp.Port = 587;
          smtp.EnableSsl = true;
          smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
          smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
          smtp.Timeout = 20000;
      }
      // Passing values to smtp object
      smtp.Send(fromAddress, toAddress, subject, body);
  }


ya然后我认为它会帮助你....





准备好了使用C#,. NET 2.0和Microsoft®SQLServer 2005 Service Broker的大量电子邮件功能[ ^ ]
ya then i think it will helps you....


Ready-to-use Mass Emailing Functionality with C#, .NET 2.0, and Microsoft® SQL Server 2005 Service Broker[^]


这篇关于发送邮件的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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