View Single Post
 
Old 04-01-2020, 02:53 PM
NightWalker NightWalker is offline Windows 10 Office 2016
Novice
 
Join Date: Apr 2020
Posts: 3
NightWalker is on a distinguished road
Default

I have the save the attachments part working but when i try to move the email to a different folder i get a run-time error 13 type mismatch. here is the new code. Could anyone shed some light on this for me. Thank you.



Code:
    For Each Item In olSubFolder.Items
        Set rsOpen = db.OpenRecordset("tbl_EmailInfo")

        For Each Attachment In Item.Attachments
            If Attachment.Type = 1 And (InStr(Attachment, "xlsx") Or InStr(Attachment, "xls")) > 0 Then
                rsOpen.AddNew
                rsOpen![DateEmailRcvd] = Item.ReceivedTime
                rsOpen![AttachmentName] = Attachment.FileName
                rsOpen.Update
               
                FileName = networkFilepath & Attachment.FileName
                Debug.Print Attachment.FileName
                Attachment.SaveAsFile FileName
            End If
        Next Attachment

        If TypeOf Item Is Outlook.MailItem Or Item.Class = 43 Or TypeOf Item Is Outlook.ReportItem Then
        Item.Move (olDestFolder)
        End If
    Next Item
Reply With Quote