![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Howdy all.
Have short VBScript that creates an Outlook obj and looks for a mail item with a specific subject line. Was wondering how to obtain the user's current inbox sort order so I can change it to descending to ensure the most recent email w/desired subject is the first mail item found and then return it to the user's previous selection. I can set the sort below but have not yet found how to obtain the current sort order... ' set sort order of inbox olInBox.Items.Sort "Received", True Appreciate your suggestions/comments. Thank you, Rey |
Ads |
#2
|
|||
|
|||
![]()
Found what works for me...and hopefully for others having encountered
similar problem. Had to define a vbScript var as olInBoxItems and SET this to the default InBox folder Items collection. Then the sort desc work. So here's the vbScript code: ' create Outlook app set objOutLook = CreateObject("Outlook.Application") 'msgbox "OutLook app obj created" set olNameSpace = objOutLook.GetNameSpace("MAPI") 'msgbox "OutLook NameSpace obj created" ' get inbox set olInBox = olNameSpace.GetDefaultFolder(olFolderInBox) 'msgbox "OutLook InBox obj created" ' set sort order of inbox - DOESN'T SORT 'olInBox.Items.Sort "[Received]", True SET olInBoxItems = olInBox.Items ' now sort desc - WORKS olInboxItems.Sort "[Received]", True ' find the email subj 'set olMailItem = olInBox.Items.Find(strFilter) set olMailItem = olInBoxItems.Find(strFilter) ' found email if not (olMailItem is Nothing) then ' file into which email body is saved to for later reading strTempFile = "\LienReleaseBody.txt" ' proc to write out & read contents of msgbody strLiens = GetAndReadMessageBody(olMailItem.Body, strTMPFolder & strTempFile) end if ' closing Outlook objs SET olInBoxItems = Nothing set olMailItem = Nothing set olInbox = Nothing set olNameSpace = Nothing set objOutLook = Nothing Similar code works in vb.net. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sort order in Address Book | David Shepard | Outlook - Using Contacts | 1 | December 18th 06 12:48 AM |
Sort order changes in Outlook | Davis | Outlook - General Queries | 0 | June 2nd 06 02:36 PM |
Retrieving Outlook Calendar Current week appointments only(vb.net) | ShilpaM | Outlook - Calandaring | 3 | May 9th 06 03:11 PM |
Sort order changes when I don't want it to | Teentour | Outlook - Using Contacts | 2 | April 6th 06 09:54 PM |
Sort Order for Contacts | Mark | Outlook - Using Contacts | 1 | March 10th 06 09:31 PM |