You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Outlook COM获取邮件时SenderEmailAddress等字段为空问题

Outlook Interop 获取邮件部分字段为空问题

正如标题所述,通过PowerShell调用Outlook Interop获取邮件时,部分字段返回空值,但在Outlook客户端中查看同一邮件时,这些邮件头信息是存在的。

Add-Type -AssemblyName "Microsoft.Office.Interop.Outlook" -ErrorAction Stop
$OutlookApp = New-Object -ComObject "Outlook.Application"

$OutlookNS = $OutlookApp.GetNamespace("MAPI")
$OutlookNS.Logon()

$RootFolder = $OutlookNS.Folders() | Where-Object { $_.FullFolderPath -eq "\\foo@bar.com" }
$TargetFolder = $RootFolder.Folders() | Where-Object { $_.Name -eq "Inbox" }

$StartDate = (Get-Date).AddDays(-1)
$EndDate = (Get-Date)

$filter = "@SQL=""urn:schemas:httpmail:datereceived"" >= '$($StartDate.ToString("MM/dd/yyyy HH:MM:ss"))' And ""urn:schemas:httpmail:datereceived"" <= '$($EndDate.ToString("MM/dd/yyyy HH:MM:ss"))'"
$MailItems = $TargetFolder.Items.Restrict($filter) | Where-Object { $_ -is [Microsoft.Office.Interop.Outlook.MailItem] }

$MailItems.Item(1) | Select-Object SenderEmailAddress, "To", Subject, SenderName, ReceivedTime, LastModificationTime

以下是某封邮件的属性检测情况:属性本身存在,但部分属性的数据为空(或对应的COM对象为空):

有数据无数据
ActionsAutoForwarded
AlternateRecipientAllowedAutoResolvedWinner
ApplicationBCC
BodyFormatBillingInformation
ClassBody
ConversationIDCategories
ConversationIndexCC
ConversationTopicCompanies
CreationTimeDeleteAfterSubmit
DeferredDeliveryTimeFlagIcon
DownloadStateFlagRequest
EnableSharedAttachmentsFlagStatus
EntryIDHasCoverSheet
ExpiryTimeHTMLBody
FlagDueByIsConflict
FormDescriptionIsIPFax
GetInspectorIsMarkedAsTask
ImportanceLinks
InternetCodepageMarkForDownload
ItemPropertiesMileage
LastModificationTimeNoAging
MAPIOBJECTOriginatorDeliveryReportRequested
MessageClassOutlookInternalVersion
ParentOutlookVersion
ReceivedByEntryIDPermission
ReceivedOnBehalfOfEntryIDPermissionService
ReceivedTimePermissionTemplateGuid
ReminderTimePropertyAccessor
RetentionExpirationDateReadReceiptRequested
SavedReceivedByName
SaveSentMessageFolderReceivedOnBehalfOfName
SenderEmailTypeRecipientReassignmentProhibited
SendUsingAccountRecipients
SentReminderOverrideDefault
SentOnReminderPlaySound
SessionReminderSet
SizeReminderSoundFile
SubjectRemoteStatus
TaskCompletedDateReplyRecipientNames
TaskDueDateReplyRecipients
TaskStartDateRetentionPolicyName
TaskSubjectRTFBody
ToDoTaskOrdinalSender
UnReadSenderEmailAddress
SenderName
Sensitivity
SentOnBehalfOfName
Submitted
To
VotingOptions
VotingResponse

内容的提问来源于stack exchange,提问作者Tyler

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 17:03:23