Link to home
Start Free TrialLog in
Avatar of ipavlo
ipavlo

asked on

VB Outlook move emails

Can anyone help with my code below to get it to remove and save the attachment then move the Email.
Code saves attachment fine but for some reason the email do not get moved -

        Dim oApp As Outlook.Application
        Dim oFolder As Outlook.MAPIFolder

        Dim oFolder3 As Outlook.MAPIFolder
        Dim oNS As Outlook.NameSpace
        Dim oMsg As Object
        Dim oAttachments As Outlook.Attachment
        Dim strControl
        Dim i As Integer
        Dim filename As String
        oApp = New Outlook.Application
        oNS = oApp.GetNamespace("MAPI")


        oFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        oFolder = oFolder.Folders.Item("fax_test")

        oFolder3 = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        oFolder3 = oFolder3.Folders.Item("THE_BRC")


        strControl = 0

        For Each oMsg In oFolder.Items ' Loop through Folder Items

            For Each oAttachments In oMsg.Attachments
                filename = "H:\ocrff\import\fax.fof\" & oAttachments.FileName
                oAttachments.SaveAsFile(filename)
             
            Next oAttachments

           oMsg.MOVE(oFolder3)

        Next oMsg
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ipavlo
ipavlo

ASKER

Thank you very much :-)
You're welcome!