怎么样用.net(c#)做外发邮件啊?

解决方案 »

  1.   

    很多阿,直接csdn搜索邮件帖子太多了。代码也很多。
      

  2.   

    http://www.c-sharpcorner.com/UploadFile/ivar/SMTPPOP3MailServer12072005040130AM/SMTPPOP3MailServer.aspx?ArticleID=56623ea9-134e-47f0-9579-ff6aa793e103
    http://www.c-sharpcorner.com/UploadFile/ivxivx/SMTPPOP3IMAPLibrary12072005012506AM/SMTPPOP3IMAPLibrary.aspx?ArticleID=01a32901-2e50-4849-9c14-8171c4dbbeff
    http://www.c-sharpcorner.com/UploadFile/sushmita_kumari/SendingMail101062006054220AM/SendingMail1.aspx?ArticleID=91ece6d8-eaaf-41ab-ac6f-533dc215eacf
      

  3.   

    MailMessage mail=new MailMessage();;
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1" ); 
    //basic authentication
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username" ); //username是你163的用户名字
    // 设置smtp服务器登录账号(如您163.com的信箱账号)password为你163邮箱的密码 当然你有自己的邮件服务器 可以用你自己邮件服务器分给你的邮件地址的用户名称 用户密码
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password"); 
    mail.To=TextBox1.Text;
    mail.From=TextBox2.Text;//这里要填你的邮箱地址,才能发送成功 比如你的163用户名字为123 那么你在这里要填[email protected]
    mail.Subject=TextBox3.Text;
    if(Format.SelectedItem.Text=="纯文本格式")
    mail.BodyFormat=MailFormat.Text;
    else
    mail.BodyFormat=MailFormat.Html;
    mail.Body=TextBox4.Text;
    SmtpMail.SmtpServer ="smtp.163.com";SmtpMail.Send(mail);
    Label1.Text="成功";