我使用 VS 2012 設計 C#寄信但出現錯誤問題,
在測試時一直出現這個程式碼有問題 smtpClient.Send(message);
錯誤訊息:無法使用信箱。 伺服器回應為: 5.7.1 Client does not have permissions to send as this sender
我公司是使用 exchange mail server
想請大大們幫忙謝謝~
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage message = new
MailMessage("寄信者", "收信者");//MailMessage(寄信者, 收信者)
message.IsBodyHtml = true;
message.BodyEncoding = System.Text.Encoding.UTF8;//E-mail編碼
message.Subject = "Mail Test.";//E-mail主旨
message.Body = "TestTest.";//E-mail內容
SmtpClient smtpClient = new SmtpClient("server", 25);//設定E-mail Server和port
smtpClient.Credentials = new System.Net.NetworkCredential("帳號", "密碼");
smtpClient.Send(message);
}
}
錯誤訊息有說:您「無權限」寄發信件喔
Client does not have permissions to send as this sender
通常要請Mail Server管理員,幫您打開權限、還有您發信的那台電腦IP也要給他
試試看 :-)