VBA中邮箱邮件的"接收时间"属性是什么,亦即outlook邮箱界面"接收时间"栏数值,而不是outlook下载接收时间.我试着用 Debug.Print vItem.CreationTime 'outlook下载接收时间 Debug.Print vItem.LastModificationTime 'outlook下载接收时间 Debug.Print vItem.ReminderTime '4501-01-01? Debug.Print vItem.ExpiryTime '4501-01-01? Debug.Print vItem.DeferredDeliveryTime '4501-01-01? 均不能达到目的. 以下在代码在Excel中,加引用outlook: Sub SaveFile() Dim strname As String Dim strFile As String Dim att Dim olApp As New Outlook.Application Dim nmsName As Outlook.Namespace Dim fldFolder ' As Outlook.Folder'此变量定义为Variant才能编译通过. Dim vItem As Object Set nmsName = olApp.GetNamespace("MAPI") Set fldFolder = nmsName.GetDefaultFolder(olFolderInbox) For Each vItem In fldFolder.Items If Month(vItem.CreationTime) = Month(Now()) And Day(vItem.CreationTime) = Day(Now()) Then If InStr(vItem.Subject, "Judge") > 0 Then Debug.Print vItem.CreationTime Debug.Print vItem.LastModificationTime Debug.Print vItem.ReminderTime Debug.Print vItem.ExpiryTime Debug.Print vItem.DeferredDeliveryTime For Each att In vItem.Attachments att.SaveAsFile "C:\" & att.Filename Debug.Print "已下载文件:" & att.Filename Next End If End If Next Set fldFolder = Nothing Set nmsName = Nothing End Sub |