我一直在做一堆關於如何從EWS交換中獲得郵件跟蹤報告的研究,而且似乎找不到任何東西。我打算構建一個刮擦日誌文件的應用程序,但是如果我可以通過EWS來完成,那麼對於我所做的更好。有任何想法嗎?EWS郵件跟蹤報告
回答
我終於能夠爲我的問題創建一個解決方案。我在C#中使用Powershell來發送命令來交換和解析消息跟蹤日誌。爲此,您需要確保您用於連接交換的用戶有權使用MessageTrackingLog作爲交換。我使用的用戶可以訪問記錄管理角色。這裏是允許我連接並獲取消息跟蹤日誌的代碼。
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Management.Automation;
using System.Collections.ObjectModel;
using System.Management.Automation.Runspaces;
using System.Security;
using System.Management.Automation.Remoting;
namespace ExchangeConnection
{
class ExchangeShell
{
//Credentials
const string userName = "username";
const string password = "password";
private PowerShell InitializePS()
{
PSCredential credential = new PSCredential(userName, SecurePassword());
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("exchange server url/Powershell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
connectionInfo.MaximumConnectionRedirectionCount = 5;
connectionInfo.SkipCNCheck = true;
connectionInfo.OpenTimeout = 999999;
Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo);
runspace.Open();
PowerShell powershell = PowerShell.Create();
powershell.Runspace = runspace;
return powershell;
}
private SecureString SecurePassword()
{
System.Security.SecureString securePassword = new System.Security.SecureString();
foreach (char c in password)
{
securePassword.AppendChar(c);
}
return securePassword;
}
public void GetMessageTrackingLog(string sender)
{
PowerShell ps = InitializePS();
ps.AddCommand("Get-MessageTrackingLog");
ps.AddParameter("Start", DateTime.Now.AddHours(-24).ToString());
ps.AddParameter("ResultSize", "Unlimited");
ps.AddParameter("Sender", sender);
ps.AddParameter("EventId", "SEND");
Collection<PSObject> results = ps.Invoke();
Console.WriteLine("|----Sender----|----Recipients----|----DateTime----|----Subject----|");
foreach (var r in results)
{
string senders = r.Properties["Sender"].Value.ToString();
string recipients = r.Properties["Recipients"].Value.ToString();
string timestamp = r.Properties["Timestamp"].Value.ToString();
string subject = r.Properties["MessageSubject"].Value.ToString();
string eventID = r.Properties["EventID"].Value.ToString();
string messageInfo = r.Properties["MessageInfo"].Value.ToString();
Console.WriteLine("{0}|{1}|{2}|{3}", sender, recipients, timestamp, subject);
}
ps.Dispose();
ps.Runspace.Dispose();
}
}
}
我認爲Office 365報告Web服務將是比EWS更好的解決方案,因爲它提供了大量適合您需求的郵件流量報告。這裏有更多信息:Office 365 Reporting web service以及所有Exchange特定報告在此處列出:Exchange reports available in Office 365 Reporting web service。 MailTraffic *報告進出組織的消息的所有報告,因此您不必親自編寫該邏輯。
你可以在內部交換服務器上使用它嗎? – cal5barton
不,只是Exchange Online/Office 365. –
這就是我遇到的問題。我有一個預置Exchange 2010服務器。 – cal5barton
- 1. Umbraco審計跟蹤報告
- 2. Git的狀態報告的跟蹤文件未經跟蹤
- 3. 跟蹤郵件
- 4. php和mysql用戶跟蹤和報告
- 5. 去bug跟蹤/報告系統?
- 6. 代碼氣味報告/跟蹤工具
- 7. Laravel 5.2郵件跟蹤器
- 8. 跟蹤電子郵件
- 9. 跟蹤郵件狀態
- 10. Google Analytics(分析)事件跟蹤報告浮誇事件值
- 11. Google Analytics(分析) - 事件跟蹤未報告
- 12. GA:我們在哪裏看到事件跟蹤報告?
- 13. Git的報告未經跟蹤的.gitignore文件,不存在
- 14. SSRS報告不會顯示在事件探查器跟蹤中
- 15. 谷歌分析事件跟蹤 - 使報告用戶友好
- 16. 用戶郵件跟蹤位置(在閱讀郵件時跟蹤用戶位置)
- 17. SSRS - 郵件執行報告
- 18. PHP郵件錯誤報告
- 19. 事件跟蹤不會在報表
- 20. 獲得警告跟蹤
- 21. 跟蹤點擊Flash廣告
- 22. 跟蹤Facebook廣告用戶
- 23. 在電子郵件上保留跟蹤
- 24. PHP跟蹤郵件和鏈接點擊
- 25. 電子郵件跟蹤 - Apple Mail
- 26. 跟蹤電子郵件回覆
- 27. 在PHP中的電子郵件跟蹤
- 28. 電子郵件跟蹤谷歌分析
- 29. 跟蹤發送的電子郵件
- 30. PHP跟蹤電子郵件和回覆
您還在尋找解決方案嗎?您的郵件跟蹤報告需要什麼信息? –
@MimiGentz是的,我仍然在尋找解決方案。我需要能夠通過收件人列表獲取每個用戶發送的所有電子郵件,以確定發送的電子郵件是內部還是外部。 – cal5barton