详细内容
.NET邮件发送程序
发布日期:2010-01-25     点击:2229     字体:[ ]
       System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
        myMail.From = "abc@sispark.com.cn";
        myMail.To = "abc@sispark.com.cn";
        myMail.Subject = "基础知识训练";
        myMail.Body = "地址已包含在邮件里~~~";
        myMail.BodyFormat = MailFormat.Html;

       //添加附件,fupload是一个文件选择框

       myMail.Attachments.Add(new MailAttachment(this.fupload.PostedFile.FileName));

        myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
        myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "用户名");
        myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "密码");

        SmtpMail.SmtpServer = "mail.sispark.com.cn";

        try
        {
            SmtpMail.Send(myMail);
        }
        catch
        { Response.Write("邮件发送错误!"); }

用户评论
昵称 
内容  *
验证码   
   
Copyright © 2010 zdbase.com All Rights Reserved. 苏ICP备15039389号 可人软件设计