FYI '=========代码部分=========== Sub test() Dim Fillrow As Long Dim myolApp As Object, myNameSpace As Object, myFolder As Object, x As Object Application.ScreenUpdating = False Sheet1.UsedRange.Clear Cells(1, 1).Value = "序号" Cells(1, 2).Value = "接收时间" Cells(1, 3).Value = "发件人" Cells(1, 4).Value = "大小" Cells(1, 5).Value = "主题" Cells(1, 6).Value = "正文" Fillrow = 2 Set myolApp = CreateObject("Outlook.Application") Set myNameSpace = myolApp.GetNamespace("MAPI") Set myFolder = myNameSpace.GetDefaultFolder(6) 'olFolderInbox) For Each x In myFolder.Items Cells(Fillrow, 1).Value = Fillrow - 1 Cells(Fillrow, 2).Value = x.ReceivedTime '接收时间 Cells(Fillrow, 3).Value = xSenderName '发送人 Cells(Fillrow, 4).Value = x.Size '大小 Cells(Fillrow, 5).Value = x.Subject '主题 Cells(Fillrow, 6).Value = x.Body '正文 Fillrow = Fillrow + 1 Next Set myFolder = Nothing Set myNameSpace = Nothing Set myolApp = Nothing Cells.Columns.AutoFit End Sub
|