Extract Zipped file from Outlook mail

前端 未结 2 1167
孤城傲影
孤城傲影 2021-01-28 19:03

I\'m trying to extract an zip file from my Outlook mail.

Below is my script but its throwing an error object variable or with block variable not set.

On

<
相关标签:
2条回答
  • 2021-01-28 19:15

    Declare msg as a generic Object - you can have objects other than MailItem in the Inbox, such as ReportItem or MeetingItem.

    0 讨论(0)
  • 2021-01-28 19:31

    Try saving the zip file first then extract it, if you want to delete the zip file then try Kill (zippath & zipname )

        Dim TempFile As String
    
        For Each msg In SubFolder.Items
           If msg.UnRead = True Then
                If LCase(msg.Subject) Like "*motor*" Then
                    For Each Atchmt In msg.Attachments
                        If (Right(Atchmt.FileName, 3) = "zip") Then
    '                    MsgBox "1"
                            FileNameFolder = "C:\Temp\Folders\"
    
                            Debug.Print FileNameFolder ' Immediate Window
                            Debug.Print Atchmt.FileName ' Immediate Window
    
                            TempFile = FileNameFolder & Atchmt.FileName
    
                            Atchmt.SaveAsFile TempFile
    
                            Set oApp = CreateObject("Shell.Application")
                            oApp.NameSpace((FileNameFolder)).CopyHere oApp.NameSpace((Atchmt.FileName)).Items
    
                            Kill (TempFile)
    
                        End If
                    Next
                End If
            End If
        Next
    
    0 讨论(0)
提交回复
热议问题