将Outlook 2010中已发送文件夹中的电子邮件复制到Excel文件

我需要logging过去几年中发送的一些电子邮件,包括发送给谁,date和邮件正文。 从Outlook导出不包含date,由于某些原因,Access不会从我的公司计算机上的Outlook导入数据

我遇到了这个macros,从Outlook导出到Excel,我需要的大部分信息,但它从收件箱拉: http : //officetricks.com/outlook-email-download-to-excel/

我searchOffice VBA网站的命令,使其从发送邮件文件夹而不是收件箱,但我不断收到运行时错误438“对象不支持此属性或方法”在ReceivedByDate和CC行(下下面的For命令)。 它只发生在我发送的邮件。 我尝试将它们移动到一个单独的文件夹,并进入我的收件箱,但是当它读取从我发送的电子邮件时,macros会失败。

Sub Mail_to_Excel() ' ' Mail_to_Excel Macro ' Copies emails from Outlook to an Excel file ' Add Tools->References->"Microsoft Outlook nn.n Object Library" ' nn.n varies as per our Outlook Installation Dim Folder As Outlook.MAPIFolder Dim iRow As Integer, oRow As Integer Dim MailBoxName As String, Pst_Folder_Name As String 'Mailbox or PST Main Folder Name (As how it is displayed in your Outlook Session) MailBoxName = "MyName@Company.com" 'Mailbox Folder or PST Folder Name (As how it is displayed in your Outlook Session) Pst_Folder_Name = "Sent Items" Set Folder = Outlook.Session.Folders(MailBoxName).Folders(Pst_Folder_Name) If Folder = "" Then MsgBox "Invalid Data in Input" GoTo end_lbl1: End If 'Read Through each Mail and export the details to Excel for Email Archival ThisWorkbook.Sheets(1).Activate Folder.Items.Sort "Received" 'Insert Column Headers ThisWorkbook.Sheets(1).Cells(1, 1) = "Sent to" ThisWorkbook.Sheets(1).Cells(1, 2) = "Copied" ThisWorkbook.Sheets(1).Cells(1, 3) = "Subject" ThisWorkbook.Sheets(1).Cells(1, 4) = "Date" ThisWorkbook.Sheets(1).Cells(1, 5) = "Size" ThisWorkbook.Sheets(1).Cells(1, 6) = "Body" 'Insert Mail Data For iRow = 1 To 5 'Folder.Items.Count oRow = iRow + 1 ThisWorkbook.Sheets(1).Cells(oRow, 1).Select ThisWorkbook.Sheets(1).Cells(oRow, 1) = Folder.Items.Item(iRow).ReceivedByName ThisWorkbook.Sheets(1).Cells(oRow, 2) = Folder.Items.Item(iRow).CC ThisWorkbook.Sheets(1).Cells(oRow, 3) = Folder.Items.Item(iRow).Subject ThisWorkbook.Sheets(1).Cells(oRow, 4) = Folder.Items.Item(iRow).ReceivedTime ThisWorkbook.Sheets(1).Cells(oRow, 5) = Folder.Items.Item(iRow).Size ThisWorkbook.Sheets(1).Cells(iRow, 6) = Folder.Items.Item(iRow).Body Next iRow MsgBox "Outlook Mails Extracted to Excel" end_lbl1: End Sub 

尝试SentOn https://msdn.microsoft.com/en-us/library/office/ff864408.aspx而不是ReceivedTime。

您可能对两者之间的差异感兴趣。 MAPI Outlook对象模型Mailitem.senton> Mailitem.receivedtime,这怎么可能?

“已发送邮件”文件夹中的某些项目不会是mailitems,因此可能没有.CC属性。

你需要一个testing

 If Item(iRow).class = olMail then