首页 文章

Outlook 2010 VBA保存特定日期的附件

提问于
浏览
0

我正在尝试修改宏以保存今天到达的电子邮件中的所有附件 . 问题是我不知道如何在Outlook VBA中引用电子邮件对象的日期属性 .

我怎么能这样做,更重要的是我怎样才能找到下次自己引用物体的方法?我没有找到很多关于outlook对象模型的参考资料 .

我现有的代码如下:

Sub GetAllAttachments() 'Exports and saves all attachements in the inbox

Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer

Today = Format(Now(), "yyyy MM dd")

Set ns = GetNamespace("MAPI")
Set Inbox = ns.Folders("Secondary")
Set Inbox = Inbox.Folders("Inbox")

i = 0

If Inbox.Items.Count = 0 Then
   MsgBox "There are no messages in the Inbox.", vbInformation, _
          "Nothing Found"
   Exit Sub
End If

For Each Item In Inbox.Items
    If EMAIL_DATE = Today Then
        For Each Atmt In Item.Attachments
                   FileName = "C:\Email Attachments\" & Atmt.FileName
                   Atmt.SaveAsFile FileName
                   i = i + 1
        End If
    Next Atmt
Next Item

End Sub

1 回答

  • 0

    项目没有日期属性 .

    尝试使用

    Outlook.MailItem
    

    例如:

    Dim oMI as Outlook.MailItem
    
     For Each oMI in Application.ActiveExplorer.Selection
         Msgbox (oMI.RecievedTime)
     Next
    

    您需要从当时剥离日期 .

相关问题