发送带有附件的邮件示例代码 下面的 C# 示例代码将包含一个演示如何发送带有附件的电子邮件的 Windows 控制台程序。这将由创建类 MessageAttachment 的实例,然后将其添加到 Attachments 集合来完成。
using System; using System.Web.Mail;
namespace CodeGuru.SendMail { /// <summary> /// console application to demonstrate sending e-mail with an /// attachment. /// </summary> class TestMail { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { TestMail.SendAttachment("testuser@codeguru.com", "mstrawmyer@crowechizek.com", "Test Message Using CDOSYS", "Hello World! This is a simple message sent using CDOSYS.", "c:\\myattachment.txt");