Outlook inbox rule to get attachments' filename without actually downloading the attachments

依然范特西╮ 提交于 2019-12-13 09:47:59

问题


I'm trying to set up an incoming rule to get the attachments' filename and write them to excel automatically without having to download the attachments itself. Is there anyway to do this with POP3 or IMAP in Outlook VBA?


回答1:


How about something like:

Dim Item As Outlook.MailItem
Item.Attachements(1).FileName

https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/attachment-filename-property-outlook




回答2:


Try The code below .. It helps you to go through your inbox folder and get every attachment filename ..

Sub test()
    Dim a As Attachments
    Dim myitem As Folder
    Dim myItemI As Object
    Dim j As Long
    Dim i As Integer

    ' Your Inbox folder
    Set myitem = Session.GetDefaultFolder(olFolderInbox)

    ' Loop through all mails in Inbox Folder
    For i = 1 To myitem.Items.Count
        'Get the mail number i
        Set myItemI = myitem.Items(i)
        'Get the attachments of the mail number i
        Set a = myItemI.Attachments
        ' if the mail contains attachments
        If Not a Is Nothing Then
            'Go through and display each attachment filename
            For j = 1 To myItemI.Attachments.Count
              MsgBox myItemI.Attachments.Item(j).DisplayName
            Next j
        End If
    Next i

End Sub


来源:https://stackoverflow.com/questions/50021295/outlook-inbox-rule-to-get-attachments-filename-without-actually-downloading-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!