C#之SYSTEM.NET.MAIL类演示例子
2013-06-12 10:35
141 查看
比较顺利。。。
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Net.Mail; namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string file = "E:\\bar.txt"; MailAddress from = new MailAddress("aguncn@163.com"); MailAddress to = new MailAddress(textBox2.Text); MailMessage message = new MailMessage(from, to); message.Subject = textBox1.Text; message.Body = richTextBox1.Text; Attachment myAttachment = new Attachment(file, System.Net.Mime.MediaTypeNames.Application.Octet); System.Net.Mime.ContentDisposition disposition = myAttachment.ContentDisposition; disposition.CreationDate = System.IO.File.GetCreationTime(file); disposition.ModificationDate = System.IO.File.GetLastWriteTime(file); disposition.ReadDate = System.IO.File.GetLastAccessTime(file); message.Attachments.Add(myAttachment); SmtpClient client = new SmtpClient("smtp.163.com", 25); client.Credentials = new System.Net.NetworkCredential("aguncn@163.com", "********"); client.Send(message); MessageBox.Show("发送成功"); } } }
相关文章推荐
- c# 模拟get请求例子,演示Session会话状态。
- C#中练习属性使用的一个例子
- C#学习之简单的WCF例子
- C#简单的UDP通信例子
- C#使用GMAIL群发带附件邮件的例子
- 单件模式(Singleton创建型)c#简单例子
- 百度webuploader 上传演示例子
- 观察者模式(observer)之委托(delegate) c#简单例子
- 一个简单的C#多线程间同步的例子 from 小菜鸟之家~ASP.NET 入门中
- C# 中使用事务的例子
- MDI窗口演示C#
- 委托和事件C#演示代码
- c# BackGroundWorker 多线程操作的小例子
- C# 执行bat批处理文件的小例子
- 正则表达式--C#正则表达式的符号及例子
- c#简单的组播例子
- 理解C#中事件和委托的例子
- JAVA调用C#发布的webservice简单例子,java.lang.NoSuchMethodError: org.apache.ws.commons.schema.XmlSchemaComplexType.getAttributes()解决
- MSDN中回调函数的讲解及其C#例子:用委托实现回调函数
- C# ASP.NET 通用权限管理系统组件源码中WCF例子程序服务器端运行详细配置参考