我使用的是自己企业的邮箱,为什么发给自己企业的没问题,但没办法发到外面的邮箱如163.QQ等,但用outlook却可以,我是用微软自带的 SmtpClient 代吗如下:
SmtpClient smtpClient = new SmtpClient(); smtpClient.Credentials = new System.Net.NetworkCredential(mailaccount, mailpassword);//设置发件人身份[shen fen]的票据 smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtpClient.Host = mailadress;// "smtp." + mailMessage.From.Host; smtpClient.Send(mailMessage);
//创建SMTP1 SmtpClient smtpClient = new SmtpClient(Server.Address); smtpClient.UseDefaultCredentials = false; smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.ServicePoint.MaxIdleTime = 0; smtpClient.ServicePoint.ConnectionLimit = 1; //创建SMTP 2是否启用SSL和指定网络凭据 smtpClient = new SmtpClient(smtpSetting.ServerName, smtpSetting.Port); smtpClient.Credentials = new NetworkCredential(smtpSetting.UserName, smtpSetting.Password); smtpClient.EnableSsl = true; smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.ServicePoint.MaxIdleTime = 0; smtpClient.ServicePoint.ConnectionLimit = 1;
要多多测试,并且搜索下有没类似信息。
www.kacled.com/led/tingyuandeng/
公司把这个帐号的外发权限给关了