• 0

Outlook VBA Sort by Date


Question

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

Link to comment
https://www.neowin.net/forum/topic/1198807-outlook-vba-sort-by-date/
Share on other sites

1 answer to this question

Recommended Posts

This topic is now closed to further replies.
  • Posts

    • Except Rolling Releases. No EOL, continuous updates.
    • True, Windows 95 could barely run on systems made in 1995. Two responses, first, people did complain in the 90s about how quickly software updates obsoleted hardware, so it isn't like it was fine then and not now. Second, it hits a little different when the requirement is seemingly arbitrary instead of a true resource requirement.
    • Go from ZERO to ADVANCED with this Microsoft Training Bundle + Office 2021 Pro Plus by Steven Parker Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where you can save 79% off Microsoft Office Pro Plus 2021 + Microsoft Training Bundle: ZERO to ADVANCED. This bundle consists of the following items: Microsoft Training Bundle: ZERO to ADVANCED LearningWhilePracticing | 6 Lessons (25h) | Lifetime $20.00 Value The Microsoft Training Bundle is the ultimate course for those looking to master Microsoft Office. With comprehensive lessons that cover Excel, Word, Access, and PowerPoint, you'll go from beginner to advanced user in no time. Learn in-demand skills like VLOOKUP and XLOOKUP in Excel, and conditional formatting to make your data stand out. With this bundle, you'll have all the tools you need to succeed in the workplace and beyond. Access 6 courses & 25 hours of content 24/7 Learn to create workbooks & spreadsheets Explore the readily available document templates Protect a file with a password & recover an unsaved document Build effective database solutions for unique data needs Create a PowerPoint presentation from scratch Create slides, textboxes & formatting text and paragraphs Perform two-dimensional lookups Discover how to calculate & highlight expiration dates What’s Included Microsoft Excel: from ZERO to ADVANCED Microsoft Word: from ZERO to ADVANCED Microsoft Access: from ZERO to ADVANCED Microsoft PowerPoint: from ZERO to ADVANCED VLOOKUP & XLOOKUP in Excel Conditional Formatting in Excel Good to know Length of time users can access this course: lifetime Access options: desktop & mobile Redemption deadline: redeem your code within 30 days of purchase Experience level required: beginner Updates included Certificate of Completion ONLY Microsoft Office Pro Plus 2021: Lifetime License One time digital license | $219.99 Value Everything a pro needs, all in one suite — that’s Microsoft Office 2021 Professional. Microsoft Office 2021 Professional is the perfect choice for any professional who needs to handle data and documents. It comes with many new features that will make you more productive in every stage of development, whether it’s processing paperwork or creating presentations from scratch – whatever your needs are! Good to know ONE-TIME PURCHASE FOR 1 PC Redemption deadline: redeem your code within 30 days of purchase This is NOT compatible with MS Office on Parallels Pro and other Virtual Machines Access options: desktop No subscriptions – no monthly/annual fees Version: Office 2021 Pro All languages supported Updates included Here's the deal: This Microsoft Office Pro Plus 2021 + Microsoft Training Bundle: ZERO to ADVANCE bundle normally costs $239.99, but you can get it for just $49.99 for a limited time - that's a saving of $189 or 79% off. For a full description, specs, and instructor info, click the link below. Get Office 2021 Pro + Office Training Bundle deal for just $49.99, or learn more Although priced in U.S. dollars, this deal is available for digital purchase worldwide. We post these because we earn commission on each sale so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: Neowin benefits from revenue of each sale made through our branded deals site powered by StackCommerce.
    • This article is about older builds of Windows 11 losing support, there have been no system requirements changes for any version of Windows 11. You were probably talking about Windows 10...but that is a an off-topic comment.
    • Only if you install an LTS version. The non-LTS distros of Linux typically have much shorter support cycles than Windows. If you are the kind of person who, for whatever reason, doesn't want to move to newer builds, simply "install linux" would make it worse, not better.
  • Recent Achievements

    • Week One Done
      Stephen Leibowitz earned a badge
      Week One Done
    • Week One Done
      Homayoun Hotak earned a badge
      Week One Done
    • Dedicated
      Profit earned a badge
      Dedicated
    • One Month Later
      hhgygy earned a badge
      One Month Later
    • Week One Done
      hhgygy earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      640
    2. 2
      ATLien_0
      240
    3. 3
      Xenon
      169
    4. 4
      neufuse
      151
    5. 5
      +FloatingFatMan
      124
  • Tell a friend

    Love Neowin? Tell a friend!