Jump to content


Outlook VBA Sort by Date

vba outlook search array

  • Please log in to reply
1 reply to this topic

#1 The World Is Yours

The World Is Yours


  • Joined: 30-July 13

Posted 31 January 2014 - 00:03

I am building a code that does a search in a Outlook folder and put the body of the items together in just one item (to build a history for that case).

I am performing the search using the Find method (not sure if all correct). Once I get the search results, I'll put them in an array.

Is there a way to sort the array by date? I keep getting an error with code below:

Dim olApp As Outlook.Application
Dim olNs As Outlook.Namespace
Dim olFldr As Outlook.MAPIFolder
Dim olItms As Outlook.Items
Dim olMail As Variant
Dim MyArray() As String

Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace(”MAPI”)
Set olFldr = olNs.GetDefaultFolder(olFolderInbox)
Set olItms = olFldr.Items

Set olMail = olItms.Find("[Subject] = ""*140115LS*""")
If Not (olMail Is Nothing) Then

MyArray = olMail.Display

#2 snaphat (Myles Landwehr)

snaphat (Myles Landwehr)

    Electrical & Computer Engineer

  • Tech Issues Solved: 29
  • Joined: 23-August 05
  • OS: Win/Lin/Bsd/Osx
  • Phone: dumb phone

Posted 31 January 2014 - 04:12

http://msdn.microsof...e/ff866960.aspx ?