The GetDefaultFolder method returns a Folder object from a message store.
Set objFolder = objSession.GetDefaultFolder(folderType)
folderType setting |
Decimal value |
Meaning |
---|---|---|
CdoDefaultFolderInbox | 1 | The CDO for NTS Library's Inbox. |
CdoDefaultFolderOutbox | 2 | The CDO for NTS Library's Outbox. |
The GetDefaultFolder method allows you to obtain the message store's default Inbox or Outbox folder. No other folders are accessible through this method.
This code fragment uses the GetDefaultFolder method to obtain the Inbox folder from a message store:
Dim objSession As Session
Dim objInbox As Folder ' default Inbox or Outbox
Dim collMessages As Messages ' messages in folder
Set objSession = CreateObject ("CDONTS.Session")
objSession.LogonSMTP("My Name", "myaddress@mycompany.com")
Set objInbox = objSession.GetDefaultFolder(CdoDefaultFolderInbox)
If objInbox Is Nothing Then
Set collMessages = Nothing
MsgBox "Unable to retrieve default folder"
Exit Function
Else
Set collMessages = objInbox.Messages
MsgBox "Folder set to " & objInbox.Name
End If