1

CDO.Message電子メールを送信するオブジェクトを作成する従来の ASP ページがあります。このコードは Window Server 2003 では機能しますが、2008 では機能しません。2008 では、「アクセスが拒否されました」というエラーがスローされます。これは、問題を診断するために私が書いた簡単なテスト ページです。これを Windows Server 2008 で動作させるにはどうすればよいですか?


dim myMail
Set myMail=CreateObject("CDO.Message")
If Err.Number <> 0 Then
    Response.Write ("Error Occurred: ")
    Response.Write (Err.Description)
Else
    Response.Write ("CDO.Message was created")
    myMail.Subject="Sending email with CDO"
    myMail.From="sender@mycompany.com"
    myMail.To="recipient@mycompany.com"
    myMail.TextBody="This is a message."
    myMail.Send
    set myMail=nothing
End If
4

2 に答える 2

0

CDO.Message オブジェクトを Windows Server 2008 で動作させることはできませんでしたが、回避策を見つけました。Windows Server 2008 で動作する電子メール クラスを作成しました。これが誰かの役に立てば幸いです。

[ComVisible(true)]
public class Email
{
    public bool SendEmail(string strTo, string strFrom , string strSubject, string strBody)
    {
        bool result = false;

        try
        {
            MailMessage message = new MailMessage();
            SmtpClient client = new SmtpClient("smtp.mycompany.com");

            List<string> to = recipientList(strTo);
            foreach (string item in to)
            {
                message.To.Add(new MailAddress(item));
            }
            message.From = new MailAddress(strFrom);
            message.Subject = strSubject;
            message.Body = strBody;

            client.Send(message);

            result = true;
        }
        catch
        {
            result = false;
            throw;
        }
        return result;
    }

    private List<string> recipientList(string strTo)
    {
        List<string> result = new List<string>();
        string[] emailAddresses = strTo.Split(new Char[]{',',';'});
        foreach (string email in emailAddresses)
        {
            result.Add(email.Trim());
        }
        return result;
    }
}
于 2010-01-08T16:15:22.510 に答える
0

Microsoft SMTP サーバー (1) を使用している限り、IIS メタベース エクスプローラーを使用して、IIS_USRS グループ (2) に、/LM/SmtpSvc/ および /LM/SmtpSvc/1/ ノードへの読み取りアクセス権を付与できます。 IIS メタベース。

残念ながら、この解決策は Windows 7 には適用されませ。Microsoft はWindows 7 に SMTP サーバーを同梱していないため、コードをリファクタリングせずにこの問題を回避することは非常に困難です。

(1) http://www.itsolutionskb.com/2008/11/installing-and-configuring-windows-server-2008-smtp-serverを参照してください。

(2) http://blogs.msdn.com/b/akashb/archive/2010/05/24/error-cdo-message-1-0x80040220-the-quot-sendusing-quot-configuration-value-is-を参照無効な iis-7-5.aspx

于 2011-02-08T16:44:18.080 に答える