Outlook VBA для загрузки вложений - PullRequest
0 голосов
/ 17 февраля 2020

Я не думаю, что VBA загружает вложения в указанную папку в коде.

Любые идеи приветствуются. Спасибо.

Я проверил, и есть 2 похожих вопроса, у которых такая же проблема еще не решена.

Public WithEvents olItems As Outlook.Items

Private Sub Application_Startup()
    Set olItems = Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub olItems_ItemAdd(ByVal Item As Object)
    Dim NewMail As Outlook.MailItem
    Dim Atts As Attachments
    Dim Att As Attachment
    Dim strPath As String
    Dim strName As String

    If Item.Class = olMail Then
       Set NewMail = Item
    End If

    Set Atts = Item.Attachments

    If Atts.Count > 0 Then
       For Each Att In Atts
           'Replace "test" with what you want to look for in attachment name
           If InStr(LCase(Att.FileName), "Test") > 0 Then
              'Use your wanted destination folder path to save the attachments
              strPath = "C:\attachments"
              strName = NewMail.Subject & " " & Chr(45) & " " & Att.FileName
              Att.SaveAsFile strPath & strName
           End If
       Next
    End If
End Sub
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...