Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort method (VBA Outlook)

Status
Not open for further replies.

mariocq

MIS
Apr 20, 2001
61
US
Hi,

I'm trying to create a button to send to the clipboard the dates and subjects of all the emails in the current folder but I can't get them sorted by subject! I'm using the 'Sort' method but doesn't seem to work at all (doesn't generate an error but doesn't sort my items neither).

Any idea of what I'm doing wrong? Here's the code if you wanna take a look. THANKS!


Dim app As Outlook.Application
Dim nameSpace As nameSpace
Dim currentFolder As MAPIFolder
Dim st As String

Set app = CreateObject("Outlook.Application")
Set nameSpace = app.GetNamespace("MAPI")
Set currentFolder = app.ActiveExplorer.currentFolder
Set myItems = app.ActiveExplorer.currentFolder.Items

' currentFolder.Items.IncludeRecurrences = True

myItems = myItems.Sort("[Subject]")

For k = 1 To currentFolder.Items.Count

st = st & "Sent: " & currentFolder.Items(k).SentOn & _
" Subject: " & currentFolder.Items(k).Subject & " " & vbNewLine
Next

ClipBoard_SetData (st)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top