我剛出生在ASP.Net籃子裏的寶貝。我正在閱讀ASP.NET 4.0的Wrox初學者,並閱讀了關於使用System.Net.Mail發送郵件的信息。通過System.Net.Mail發送郵件
protected void Page_Load(object sender, EventArgs e)
{
MailMessage myMessage = new MailMessage(); // Getting Error
myMessage.Subject = "Test Message";
myMessage.Body = "Hello World, from Planet Wrox";
myMessage.From = new MailAddress("[email protected]", "Barack Obama");
myMessage.To.Add(new MailAddress("[email protected]", "George Bush"));
SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.Send(myMessage);
}
我在頁面加載事件中寫了這段代碼。但我得到的錯誤在第一線爲
Server Error in '/' Application.
The specified string is not in the form required for an e-mail address. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: The specified string is not in the form required for an e-mail address.
Source Error:
Line 11: protected void Page_Load(object sender, EventArgs e)
Line 12: {
Line 13: MailMessage myMessage = new MailMessage();
Line 14: myMessage.Subject = "Test Message";
Line 15: myMessage.Body = "Hello World, from Planet Wrox";
任何一個能告訴什麼問題呢?
羞恥促進這種行爲,但+1短語「我只是出生的嬰兒在ASP.Net籃子裏。」太有趣了! –
@KileyNaro:非常感謝Kilet :) – Sandy