【发布时间】:2022-07-14 04:58:01
【问题描述】:
我正在尝试获取已收到邮件的“收件人”部分中的所有电子邮件地址。
此代码为每个电子邮件地址提供一个链接。
"/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=636da3beeae34f2493a3ee2c93d44007-LC",
其中 LC 是接收邮件的帐户的显示名称。
Sub openLeaseInbox()
Dim oOutlook As Outlook.Application
Dim oFolder As Outlook.Folder
Dim oMailBox As String
Dim oFldr As String
Dim XDate As Date
Dim i As Integer
Dim olMail As Outlook.MailItem
Dim olrecips As Outlook.Recipients
Dim olrecip As Outlook.Recipient
Dim LR As Integer
Range("L2").Value = "3/20/2022"
XDate = Format(ThisWorkbook.Sheets("Email Download").Range("L2").Value, "mm/dd/yyyy")
Set oOutlook = CreateObject("Outlook.Application")
Set oNS = oOutlook.GetNamespace("MAPI")
oMailBox = "Lease QC"oFldr = "Inbox"
Set oFolder = oNS.Folders(oMailBox).Folders(oFldr)
If (oOutlook.ActiveExplorer Is Nothing) Then
oFolder.Display
Else
Set oOutlook.ActiveExplorer = oFolder
End If
i = 1
For Each olMail In oFolder.Items.Restrict("[ReceivedTime] < '" & XDate & "' ")
Set olrecips = olMail.Recipients
Range("A1").Offset(i, 0).Value = olMail.Subject
Range("B1").Offset(i, 0).Value = olMail.ReceivedTime
For Each olrecip In olrecips
Range("C1").Offset(i, 0).Value = olrecip.Address ' Seems there is a problem here'
Next
Range("D1").Offset(i, 0).Value = olMail.body
i = i + 1
Next olMail
End Sub
【问题讨论】:
-
很抱歉,我对 VBA 不是很精通,并且无法将建议的解决方案合并到我现有的代码中,您能否提出一个更简单的解决方案或让我知道如何将建议的解决方案合并到我现有的代码