Загрузите вложение из Outlook и откройте в Excel

Я пытаюсь загрузить, а затем открыть вложение электронной таблицы Excel в электронном письме Outlook, используя VBA в Excel. Как я могу:

Download the one and only attachment from the first email (the newest email) in my Outlook inbox Save the attachment in a file with a specified path (eg: "C:...") Rename the attachment name with the: current date + previous file name Save the email into a different folder with a path like "C:..." Mark the email in Outlook as "read" Open the excel attachment in Excel

Я также хочу иметь возможность сохранить следующее как отдельные строки, назначенные отдельным переменным:

Sender email Address Date received Date Sent Subject The message of the email

хотя это может быть лучше задать в отдельном вопросе / поискать это сам.

Код, который у меня есть в настоящее время, взят с других онлайн-форумов и, вероятно, не очень полезен. Тем не менее, вот некоторые кусочки, над которыми я работал:

Sub SaveAttachments()
    Dim olFolder As Outlook.MAPIFolder
    Dim att As Outlook.Attachment
    Dim strFilePath As String
    Dim fsSaveFolder As String

    fsSaveFolder = "C:\test\"

    strFilePath = "C:\temp\"

    Set olFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)

    For Each msg In olFolder.Items
        While msg.Attachments.Count > 0
            bflag = False
            If Right$(msg.Attachments(1).Filename, 3) = "msg" Then
                bflag = True
                msg.Attachments(1).SaveAsFile strFilePath & strTmpMsg
                Set msg2 = Application.CreateItemFromTemplate(strFilePath & strTmpMsg)
            End If
            sSavePathFS = fsSaveFolder & msg2.Attachments(1).Filename


    End If
End Sub

Ответы на вопрос(2)

Ваш ответ на вопрос