MailMessage mail = new MailMessage();
                mail.From = "[email protected]";
                mail.To = "[email protected]";
                mail.BodyFormat = MailFormat.Text;
                mail.Body = "a test smtp mail.";
                mail.Subject = "r u ok?";
                mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication 
                mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "[email protected]"); //这句我网上好多的例子都是不是邮箱
但在UTLOOK里设要设整个邮箱啊,在ASP里做也是这样的不知我这样设对不对
                mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "****"); //set your password here 
                SmtpMail.SmtpServer = "smtp.sohu.com";
                SmtpMail.Send(mail);请帮忙看下我这里是那里不行。。
using System.Web.Util;
using System.Web.Mail;
这两个我都是引用了的

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Net;
    using System.IO;
    using System.Data.SqlClient;
    using System.Web.Mail;
    using System.Net.Mail;
    namespace FptDownLoad
    {
        public partial class Form1 : Form
        {
            private string SqlConn = System.Configuration.ConfigurationSettings.AppSettings["SqlConn"];
            private string FilePath = System.Configuration.ConfigurationSettings.AppSettings["FilePath"];
            public Form1()
            {
                    SendMial("接收异常:"+ex.ToString());
            }        private void SendMial(string Msg)
            {
                SmtpClient client = new SmtpClient(System.Configuration.ConfigurationSettings.AppSettings["MailServer"]);            //验证
                client.UseDefaultCredentials = true;
                client.Credentials = new System.Net.NetworkCredential(System.Configuration.ConfigurationSettings.AppSettings["SendAddress"],               
                System.Configuration.ConfigurationSettings.AppSettings["SendPwd"]);            client.DeliveryMethod = SmtpDeliveryMethod.Network;            MailAddress from = new MailAddress(System.Configuration.ConfigurationSettings.AppSettings["SendAddress"]);
                MailAddress to = new MailAddress(System.Configuration.ConfigurationSettings.AppSettings["ReciveAddress"]);
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(from, to);
                message.Body = Msg;
                message.BodyEncoding = System.Text.Encoding.UTF8;
                message.Subject = "SODGC_AutoRecive";
                message.SubjectEncoding = System.Text.Encoding.UTF8;            try
                {
                    client.Send(message);
                }
                catch (System.Net.Mail.SmtpException ex)
                {
                    StreamWriter sw = new StreamWriter(Application.StartupPath + @"\Log.txt", true, System.Text.Encoding.Default);
                    sw.Write("\r\n" + DateTime.Now.ToString() + ":" + ex.ToString());
                    sw.Close();
                }
            }
        }
    }
      

  2.   

    看不懂在那里设SMTP和邮箱和密码呀。。兄弟帮忙说一下
      

  3.   

    主要是sohu现在还支持smtp不??
    要是不支持了就没法了!
      

  4.   


                dt = new DataTable();
                dt.Columns.Add("name");
                dt.Columns.Add("Email");    private void mailto()
        {
            if (dt.Rows.Count > 0)
            {
                string err = "";
                foreach (DataRow row in dt.Rows)
                {
                    string strHost = "mail.esunsoft.net";   //STMP服务器地址
                    string strAccount = "[email protected]";       //SMTP服务帐号
                    string strPwd = "SMTP服务密码";       //SMTP服务密码
                    string strFrom = "[email protected]"; //发送方邮件地址                System.Net.Mail.SmtpClient _smtpClient = new System.Net.Mail.SmtpClient();
                    _smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;//指定电子邮件发送方式
                    _smtpClient.Host = strHost; ;//指定SMTP服务器
                    _smtpClient.Credentials = new System.Net.NetworkCredential(strAccount, strPwd);//用户名和密码                System.Net.Mail.MailMessage _mailMessage = new System.Net.Mail.MailMessage(strFrom, row["Email"].ToString());
                    _mailMessage.Subject = row["name"] + "邀请你加入商商网";//主题
                    _mailMessage.Body = @"内容";//内容
                    _mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//正文编码
                    _mailMessage.IsBodyHtml = true;//设置为HTML格式
                    _mailMessage.Priority = System.Net.Mail.MailPriority.High;//优先级                try
                    {
                        _smtpClient.Send(_mailMessage);
                        err += row["Email"].ToString() + "发送成功!\\n";
                    }
                    catch
                    {
                        err += row["Email"].ToString() + "发送失败!\\n";
                    }
                }
                if(err!="")
                        Label1.Text = "<script>alert('"+err+"')</script>";
            }
        }
      

  5.   


    支持的OUTLOOK可以发送我的一个站用ASP就是用的这个邮箱