[英]Outlook 2010 VBA save attachments for certain date
I am trying to modify a macro to save all attachemnts from emails that arrived today. 我正在尝试修改宏,以保存今天收到的电子邮件中的所有附件。 The problem is that I do not know how to reference the date property of an email object in Outlook VBA. 问题是我不知道如何在Outlook VBA中引用电子邮件对象的date属性。
How can I do this and more importantly how can I find out how to reference objects on my own next time? 我该怎么做,更重要的是我下次如何找到引用对象的方法? I am not finding much reference material for the outlook object model. 我没有为Outlook对象模型找到太多参考资料。
my existing code is below: 我现有的代码如下:
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
Item doesn't have the date property. 项目没有date属性。
Try using the 尝试使用
Outlook.MailItem
For example: 例如:
Dim oMI as Outlook.MailItem
For Each oMI in Application.ActiveExplorer.Selection
Msgbox (oMI.RecievedTime)
Next
You will need to strip the date from the time. 您将需要从时间中删除日期。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.