3

Outlookは、アカウント設定を使用して電子メールを送信できます。しかし、C#からメールを送信できません。

これが私のアカウント設定です:

Microsoft exchange server: exch.server1.com;
User name: user1@server1.com;
Password: password1;

-----セキュリティタブ-----

Encrypt data between Microsoft Office Outlook and Microsoft Exchange - CHECKED;
Logon network security: Negotiate Authentication;

-----接続タブ-----

Connect using my Local Area Network (LAN) - SELECTED;
Connect to Microsoft Exchange using HTTP - CHECKED;

-----Exchangeプロキシ設定フォーム-----

Use this email to connect to my proxy server fo Exchange: https://owa.server1.com
Connect using SSL only - CHECKED;
Only connect to proxy servers that have this principal name in their certificate: msstd:owa.server1.com;
Proxy authentication settings: NTLM Authentication;

これが私のC#コードです:

var completeMessage = new MailMessage();
completeMessage.From = new MailAddress("ivanov@server1.com");
completeMessage.To.Add("ivanov@server1.com");
completeMessage.Subject = "test subject";
completeMessage.Body ="test body";
var client = new SmtpClient("exch.server1.com");
client.Credentials = new NetworkCredential("user1@server1.com", "password1");
client.Send(completeMessage);

次の例外が発生します。 The remote name could not be resolved: 'exch.server1.com'

このURL「exch.server1.com」は私のオフィスからブロックされています。メールを送信するようにSmtpClientを構成する方法を教えてください。

4

0 に答える 0