我正在使用以下代碼使用“MarkAsJunk”方法將電子郵件標記為垃圾郵件,該方法可以很好地阻止整個發件人([email protected]):
private static void MarkMessageAsJunk(ExchangeService service, ItemId messageId, bool isJunk, bool moveItem)
{
List<ItemId> junkItemIds = new List<ItemId>();
junkItemIds.Add(messageId);
ServiceResponseCollection<MarkAsJunkResponse> responseCollection = null;
try
{
// If isJunk is true, the sender of the email message is added to
// the Blocked Senders List. If isJunk is false, the sender is removed
// from the list (if present).
responseCollection = service.MarkAsJunk(junkItemIds, isJunk, moveItem);
}
catch (ServiceResponseException ex)
{
Console.WriteLine("Error marking item as junk: {0}", ex.ErrorCode);
return;
}
foreach (MarkAsJunkResponse response in responseCollection)
{
if (response.Result == ServiceResult.Success)
{
Console.WriteLine("Successfully marked message as {0}junk.", isJunk ? "": "NOT ");
if (moveItem)
{
Console.WriteLine("New item ID: {0}", response.MovedItemId.ToString());
}
}
else
{
Console.WriteLine("[{0}]: {1}", response.Result.ToString(),
response.ErrorCode.ToString());
}
}
}
當我檢查 Outlook 中的垃圾郵件設定時,我可以看到被阻止的發件人。在 Outlook 中,我可以通過僅定義“@xyz.com”之類的域來添加新條目,甚至可以只定義“xyz.com”。如何使用 EWS 做到這一點?我是否需要能夠從messageId生成的郵件中修改發件人/來自地址(洗掉@之前的所有內容),這甚至可能嗎?有人有想法嗎?
非常感謝。
uj5u.com熱心網友回復:
除了您正在使用的內容之外,EWS 中沒有任何內容可以讓您輕松管理郵箱中的 SafeSender 串列。其基礎存盤在擴展規則物件上,因此您可以使用 EWS 直接修改擴展屬性,例如 PidTagExtendedRuleMessageCondition 和 Blob 格式在此處描述 MS-OXCSPAM https://learn.microsoft.com/en-us/openspecs/exchange_server_protocols/ms -oxcspam/70e414e0-1798-47a0-a439-9ee3dc641a9e和 MS-OXORULE 分別(如果您使用 MFCMapi 的 OutlookSpy,您應該能夠看到垃圾郵件配置物件)
一個更簡單的選擇是使用 cmdlet 而不是https://learn.microsoft.com/en-us/microsoft-365/security/office-365-security/configure-junk-email-settings-on-exo-mailboxes ?view=o365-全球
另一種選擇是使用 MAPI 和 Redemption,這使得這更容易,例如 https://www.dimastr.com/redemption/rdojunkemailoptions.htm
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/513312.html
