0
我试图修改宏以保存今天到达的电子邮件中的所有附件。问题是我不知道如何引用Outlook VBA中的电子邮件对象的日期属性。Outlook 2010 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
好的,让我来解决这个问题,看看它是怎么回事。 – timbram 2014-10-21 15:27:25
它一直抱怨对象不支持这种方法。 – timbram 2014-10-21 15:51:55
给定“Dim oMI as Outlook.MailItem”,您只能选择邮件项目。 – niton 2014-10-25 13:25:21