Sort Method


Sort emails in current collection.

void Sort([in] BSTR Sort)

Parameters

Sort

Sort descriptor, the format is: "sort=[sort type];order=[order type]". e.g. "sort=date;order=ascent" means sorting emails by date ascent. sort type can be date, subject, from, to or size. order type can be ascent or descent.

Usage Example

Dim server, user, password, requestAddr
server = "localhost"
user = "hunter@emailarchitect.net"
password = "mypassword"
requestAddr = "192.168.0.1"

Dim oSvr
Set oSvr = CreateObject("EmailArchitectObjects.ServerRoot")
r = oSvr.Connect( server, user, password, 0, requestAddr )
If r <> 0 Then
  WScript.Echo( "connect server failed!" )
  WScript.Quit
End If

Dim oDomains, oDomain
Set oDomains = oSvr.DomainCollection
Set oDomain = oDomains.Items(CStr(oSvr.Domain)) 

Dim oUsers, oUser
Set oUsers = oDomain.UserCollection
Set oUser = oUsers.Items(CStr(oSvr.User))

Dim oMBXs, oMBX, oTools
Set oTools = CreateObject("EmailArchitectObjects.Tools")
Set oMBXs = oUser.MBXCollection

Set oMBX = oMBXs.Items(CStr(oTools.EncodeHex("inbox")))
Dim oMails, oMail
Set oMails = oMBX.MailCollection

oMails.Sort "sort=date;order=descent"

'enumerate all mails in "Inbox" 
Dim i, nCount
nCount = oMails.Count
For i = 0 To nCount-1
  Set oMail = oMails.Items(CLng(i))
  WScript.Echo( oMail.Subject )
Next