A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - General Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Retrieving and setting current sort order



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 3rd 08, 12:59 AM posted to microsoft.public.outlook
Rey
external usenet poster
 
Posts: 3
Default Retrieving and setting current sort order

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  
Old June 4th 08, 01:09 AM posted to microsoft.public.outlook
Rey
external usenet poster
 
Posts: 3
Default Retrieving and setting current sort order

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 08:19 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.