Results 1 to 2 of 2

Thread: Userform to File Emails

  1. #1
    VBAX Newbie
    Apr 2019

    Userform to File Emails

    Good afternoon all,

    I am trying to create a userform to file emails in my inbox to folders , the userfrom has 2 drop downs, 1st called folder, 2nd called subfolder, I then want to press file and the email goes to the selected subfolder.
    I have sucessfully created the userform and populated the comboboxes and know how to move emails using a macro just dont know how to combine the 2.

    All help greatly appricated.


  2. #2
    Assuming the first folder is a sub folder of Inbox then you need something like the following which will set the folder according to whether the combo boxes have selected values. If no folders are selected the folder is set to the Inbox

    Dim sFolder1 As String
    Dim sFolder2 As String
    Dim olFolder As Folder
        If ComboBox1.ListIndex > -1 Then
            sFolder1 = ComboBox1.Text
            sFolder2 = ""
        End If
        If ComboBox2.ListIndex > -1 Then
            sFolder2 = ComboBox2.Text
            sFolder2 = ""
        End If
        Select Case True
            Case Is = sFolder1 = "": Set olFolder = Session.GetDefaultFolder(olFolderInbox)
            Case Is = sFolder2 = "": Set olFolder = Session.GetDefaultFolder(olFolderInbox).folders(sFolder1)
            Case Else: Set olFolder = Session.GetDefaultFolder(olFolderInbox).folders(sFolder1).folders(sFolder2)
        End Select
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts