首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

vs2005邮件发布的有关问题

2011-12-29 
vs2005邮件发布的问题usingSystemusingSystem.NetusingSystem.Net.Mailpublicpartialclassfasongyoujia

vs2005邮件发布的问题
using   System;
using   System.Net;
using   System.Net.Mail;

public   partial   class   fasongyoujian   :   System.Web.UI.Page
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                string   file   =   @ "C:\Documents   and   Settings\Administrator\My   Documents\Visual   Studio   2005\WebSites\WebSite1\aaa.txt ";
                System.Net.Mail.MailMessage   message   =   new   System.Net.Mail.MailMessage( "wcs519@163.com ",   "yzhwd521@sina.com ",   "text   message   for   you. ",   "Test   Title ");
                System.Net.Mail.Attachment   data   =   new   System.Net.Mail.Attachment(file,   System.Net.Mime.MediaTypeNames.Application.Octet);
                System.Net.Mime.ContentDisposition   disposition   =   data.ContentDisposition;
                disposition.CreationDate   =   System.IO.File.GetCreationTime(file);
                disposition.ModificationDate   =   System.IO.File.GetLastWriteTime(file);
                disposition.ReadDate   =   System.IO.File.GetLastAccessTime(file);
                message.Attachments.Add(data);
                System.Net.Mail.SmtpClient   client   =   new   System.Net.Mail.SmtpClient( "smtp.163.com ");
                client.Credentials   =   new   NetworkCredential( "wcs519 ",   我的邮箱的密码);
                client.Send(message);
                data.Dispose();
}

这是我的代码,可是运行以后提示邮箱不可用,请问这是怎么回事吖

[解决办法]
換代碼: // MailMessage msg = new MailMessage();

msg.From = "***@163.com ";
msg.To = this.TextBox1.Text;
msg.Subject = "test ";
msg.Body = "test ";


msg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ", "1 ");
msg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername ", "***@163.com ");
msg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword ", "*** ");
msg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpserverport ", "25 ");


SmtpMail.SmtpServer = "192.168.*.* ";
SmtpMail.Send(msg);

[解决办法]
http://www.51aspx.com/CV/JH1GEZ9ACZA70

热点排行