本文將告訴您,如何疑難排解無法建立 'CDO.Message' 錯誤訊息。當您使用的應用程式來傳送電子郵件訊息時,可能會收到這個訊息。
錯誤訊息是由 Microsoft 共同作業資料物件 (CDO) 的問題所造成。如果一個,就會發生這個問題或多個下列情況成立,則為 True:
- Cdosys.dll 檔案未正確註冊。
- 使用者帳戶沒有足夠的權限可存取登錄機碼的 Microsoft Windows 2000 程式庫的 CDO (Cdosys.dll)。
- 用一個無效的簡易郵件傳送通訊協定 (SMTP) 虛擬伺服器,或是 SmtpMail.SmtpServer 屬性的設定不正確。
- 使用者沒有透過 SMTP 虛擬伺服器轉送電子郵件訊息的權限。
- MailMessage.From 屬性不是設定為有效的電子郵件地址。
您可能會使用一或多個下列方法來解決 CDO 問題。
警告如果您修改登錄不當使用 「 登錄編輯程式 」,或使用另一個方法,可能會發生嚴重的問題。這些問題可能會要求您重新安裝作業系統。Microsoft 無法保證可以解決這些問題。您必須自己承擔修改登錄所造成的風險。
方法 1: 請確定已正確登錄 Cdosys.dll 檔案
- 判斷是否 Cdosys.dll 檔案已正確登錄。要這麼做,請您執行下列步驟:
- 按一下 [開始],再按一下 [執行]、 輸入 regedt32,然後再按一下 [確定]]。
- 在 [登錄編輯程式] 中,找出並展開 HKEY_CLASSES_ROOT 登錄樹狀子目錄。展開 TypeLib,然後尋找 {CD000000 8B95 11 D 1-82DB-00C04FB1625D}。
- 展開 {CD000000 8B95 11 D 1-82DB-00C04FB1625D},展開 [1.0,] 然後按一下 [0。
- 按一下 win32,並確認下列的值會顯示在右側的面板:
Drive: \WINDOWS\system32\cdosys.dll
- 註冊 Cdosys.dll 檔案。要這麼做,請您執行下列步驟:
- 按一下 [開始]、 按一下 [執行]、 輸入 regsvr32 %systemroot%\system32\cdosys.dll,然後按一下 [確定]]。
附註您可能會收到 0x800704da 錯誤程式碼如果多個版本的 CDO 存在於相同的作業系統上。如果要解決這個問題,使用 regsrv32-u cdosys.dll 命令取消註冊 Cdosys.dll 檔案。藉由執行下列命令,然後,重新登錄 Cdosys.dll 檔案:regsvr32 %systemroot%\system32\cdosys.dll
如需有關 CDO 版本的詳細資訊,請造訪下列 Microsoft 開發 o 人 h 員 ? 工 u 具 ? 網路 (MSDN) 網站]:
方法 2: 將授與使用者帳戶的 Windows 2000 庫的 CDO 存取登錄機碼的權限
- 授與使用者帳戶以 Windows 2000 庫的 CDO,存取登錄機碼的權限。
- 按一下 [開始],再按一下 [執行]、 輸入 regedt32,然後再按一下 [確定]]。
- 在 [登錄編輯程式] 中,找出並展開 HKEY_CLASSES_ROOT 登錄機碼。展開 TypeLib,然後尋找 {CD000000 8B95 11 D 1-82DB-00C04FB1625D}。
- 以滑鼠右鍵按一下 {CD000000 8B95 11 D 1-82DB-00C04FB1625D},按一下 權限,] 然後按一下 [新增]。
- 型別 ComputerName \ UserName,然後按一下 [確定]
附註預留位置 ComputerName 代表電腦的名稱。版面配置區 UserName 代表使用者的名稱。 - 按一下以選取核取方塊,在 允許 資料行以讀取權限授與對使用者,然後按一下 [確定]。
方法 3: 確認設定 SmtpMail.SmtpServer 屬性為有效的伺服器 IP 位址
請確定您知道有效的 SMTP 郵件伺服器在網路上的 IP 位址。請
SmtpMail.SmtpServer 屬性的值設為有效的值。
方法 4: 設定使用者權限到透過 SMTP 服務的轉接電子郵件
- 按一下 [開始]、 按一下 [執行]、 輸入 inetmgr,然後按一下 [確定]]。
- 展開 [ComputerName,然後在有效的 SMTP 虛擬伺服器上按一下滑鼠右鍵。
附註預留位置 ComputerName 代表本機電腦的名稱。 - 按一下 [內容]。在 [安全性] 索引標籤上將使用者帳戶新增為運算子。
- 關閉所有對話框,然後重新啟動 SMTP 服務。
方法 5: 請確定 [MailMessage.From] 屬性設定為有效的電子郵件地址
使用 SMTP 伺服器的存在一個有效的寄件者的電子郵件地址。
SmtpMail.SmtpServer 屬性指向這個伺服器。請不要使用不同的虛構位址
MailMessage.From 屬性的值。
您可以設定 Cdosys.dll 檔以指向 SMTP 伺服器以程式設計的方式。此選項可讓開發人員在設定根據伺服器的應用程式設定的 SMTP 伺服器的彈性。下列是 Microsoft Visual C# Web 應用程式中的範例程式碼
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
namespace WebApplication1
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "<john@contoso.com>";
mail.From = "<ruth@contoso.com>";
mail.Subject = "This is a test email.";
mail.Body = "Some text goes here";
// The following line will cause an exception to be thrown.
SmtpMail.SmtpServer = "172.16.0.0";
try
{
SmtpMail.Send(mail);
}
catch(Exception ex )
{
Response.Write("The following exception occurred: " + ex.ToString() );
// Check the InnerException.
while( ex.InnerException != null )
{
Response.Write("--------------------------------");
Response.Write("The following InnerException reported: " + ex.InnerException.ToString() );
ex = ex.InnerException;
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
附註 的版面配置區
<john@contoso.com> 和
<ruth@contoso.com> 代表實際的電子郵件地址的使用者。
如需詳細資訊按一下 [下面的文件編號,檢視 「 Microsoft 知識庫 」 中 「 文件]:
827659?
(http://support.microsoft.com/kb/827659/
)
當您嘗試藉由使用 Regsvr32.exe 登錄一個 DLL 時,收到 DllRegisterServer"錯誤
327219?
(http://support.microsoft.com/kb/327219/
)
共同作業資料物件 Windows NT、 Windows 2000 及 Exchange 2000 需要 Outlook Express