SMTP ホストは指定されませんでした。

解决方案 »

  1.   

    using System;
    using System.Data;
    using System.Configuration;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Net.Mail;
    using System.Net;
    using System.ComponentModel;
    using System.Net.Mime;
    /// <summary>
    /// mail の概要の説明です
    /// </summary>
    /// 
    namespace business.mail
    {    public struct AppointMail
        {
            public string from;     //发件人邮箱
            public string to;        //收件人邮箱;号分隔的一个串
            public string fromDisplayName; //发件人姓名
            public string subject;  //标题
            public string body;     //正文
            public string location; //地点
            public DateTime sTime;  //开始时间
            public DateTime eTime;  //结束时间
        }    public class outlookmail
        {       
            public  void SendAppointMail(AppointMail mail)
            {
                MailMessage msg = new MailMessage();
                MailAddressCollection attendeeList = new MailAddressCollection();            string[] sendTo = mail.to.Split(';');
                foreach (string temp in sendTo)
                {
                    msg.Bcc.Add(temp);
                    attendeeList.Add(temp);
                }            System.Net.Mime.ContentType textType = new System.Net.Mime.ContentType("text/plain");
                System.Net.Mime.ContentType HTMLType = new System.Net.Mime.ContentType("text/html");
                System.Net.Mime.ContentType RTFType = new System.Net.Mime.ContentType("text/rtf");
                System.Net.Mime.ContentType calendarType = new System.Net.Mime.ContentType("text/calendar;");
                calendarType.Parameters.Add("method", "REQUEST");
                calendarType.Parameters.Add("name", "meeting.ics");
                string calDateFormat = "yyyyMMddTHHmmssZ";
                string bodyCalendar = "BEGIN:VCALENDAR\r\nMETHOD:REQUEST\r\nPRODID:Microsoft CDO for Microsoft Exchange\r\nVERSION:2.0\r\nBEGIN:VTIMEZONE\r\nTZID:(GMT-06.00) Central Time (US & Canada)\r\nX-MICROSOFT-CDO-TZID:11\r\nBEGIN:STANDARD\r\nDTSTART:16010101T020000\r\nTZOFFSETFROM:-0500\r\nTZOFFSETTO:-0600\r\nRRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nDTSTART:16010101T020000\r\nTZOFFSETFROM:-0600\r\nTZOFFSETTO:-0500\r\nRRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU\r\nEND:DAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTAMP:{8}\r\nDTSTART:{0}\r\nSUMMARY:{6}\r\nUID:{5}\r\nATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"{9}\":MAILTO:{9}\r\nACTION;RSVP=TRUE;CN=\"{4}\":MAILTO:{4}\r\nORGANIZER;CN=\"{3}\":mailto:{4}\r\nLOCATION:{2}\r\nDTEND:{1}\r\nDESCRIPTION:{7}\\N\r\nSEQUENCE:1\r\nPRIORITY:5\r\nCLASS:\r\nCREATED:{8}\r\nLAST-MODIFIED:{8}\r\nSTATUS:CONFIRMED\r\nTRANSP:OPAQUE\r\nX-MICROSOFT-CDO-BUSYSTATUS:BUSY\r\nX-MICROSOFT-CDO-INSTTYPE:0\r\nX-MICROSOFT-CDO-INTENDEDSTATUS:BUSY\r\nX-MICROSOFT-CDO-ALLDAYEVENT:FALSE\r\nX-MICROSOFT-CDO-IMPORTANCE:1\r\nX-MICROSOFT-CDO-OWNERAPPTID:-1\r\nX-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE:{8}\r\nX-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE:{8}\r\nBEGIN:VALARM\r\nACTION:DISPLAY\r\nDESCRIPTION:REMINDER\r\nTRIGGER;RELATED=START:-PT00H15M00S\r\nEND:VALARM\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
                bodyCalendar = string.Format(bodyCalendar,
                mail.sTime.ToUniversalTime().ToString(calDateFormat),
                mail.eTime.ToUniversalTime().ToString(calDateFormat),
                mail.location,
                mail.fromDisplayName,
                mail.from,
                Guid.NewGuid().ToString("B"),
                mail.subject,//summary
                mail.body,//正文
                DateTime.Now.ToUniversalTime().ToString(calDateFormat),
                attendeeList.ToString(),
                mail.body
                );
                AlternateView calendarView = AlternateView.CreateAlternateViewFromString(bodyCalendar, calendarType);
                calendarView.TransferEncoding = TransferEncoding.SevenBit;
                msg.AlternateViews.Add(calendarView);            //  Adress the message
                msg.From = new MailAddress(mail.from, mail.fromDisplayName);
                msg.IsBodyHtml = true;
               SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["mail"]);            smtpClient.Send(msg);
                      }

        }
    }
      

  2.   

      protected void BtnSend_Click1(object sender, EventArgs e)
        {
            //DBManager Mysql = new DBManager();
            outlookmail Mymail = new outlookmail();
            AppointMail mail = new AppointMail();
                 //得到收件人地址列表          
            
            for (int i = 0; i < this.ListBoxStaffL.Items.Count; i++)
            {
                ListItem lst = new ListItem();
                lst = ListBoxStaffL.Items[i];
                
                if (mail.to == null)
                {
                    mail.to = lst.Value;
                }
                else
                {
                    mail.to = mail.to + ";" + lst.Value;
                }
                
            }
            mail.from = Session["StaffMailAdd"].ToString();//发件人地址
            mail.fromDisplayName = Session["Name"].ToString();//发件者
            mail.body = this.TxtContent.Text.ToString();//邮件主体
            mail.sTime = DateTime.Parse(this.TxtBoxDate.Text.ToString() + " " + this.DDLStartHour.Text.ToString() + ":" + this.DDLStartMin.Text.ToString() + ":00");//开始时间
            mail.eTime = DateTime.Parse(this.TxtBoxDate.Text.ToString() + " " + this.DDLEndHour.Text.ToString() + ":" + this.DDLEndMin.Text.ToString() + ":00");//结束时间
            mail.subject = this.TxtTitle.Text.ToString();//邮件标题
            mail.location = this.TxtAdd.Text.ToString();//约会地址
            endTime = this.TxtBoxDate.Text.ToString() + " " + this.DDLEndHour.Text.ToString() + ":" + this.DDLEndMin.Text.ToString() + ":00";//结束时间
            Mymail.SendAppointMail(mail);
        }这是用到类的地方
      

  3.   

    SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["mail"]);
    这句话是设置发送邮件的服务器,也就是SMTP ホスト。
    要事先配置好。他已经配置到webconfig里面了。
    你没有配置所以不行。
    你可以把这句话直接换成以前发邮件的配置。
    什么服务器,用户和密码什么的把这句话改成这样
    SmtpClient smtpClient = new SmtpClient();
            smtpClient.Host = "outlook的服务器";
      

  4.   

    你把你的mailto字符串拿出来看看是什么东西。
      

  5.   

    你把这些地址放到outlook里面直接发送,看看能不能发。
      

  6.   

    真笨,发错信息了ユーザーはローカルではありません。別のパスを指定してください。 サーバーの応答: User not local; please try <forward-path>
      

  7.   

    你把你的mailto发给我看看。
      

  8.   

    你把这些地址放到outlook里面直接发送,看看能不能发。
    能发吗