Folders.GetFirst method (Outlook)
Returns the first object in the Folders collection.
Syntax
expression. GetFirst
expression A variable that represents a Folders object.
Return value
A Folder object that represents the first object contained by the collection.
Remarks
Returns Nothing if no first object exists, for example, if there are no objects in the collection.To ensure correct operation of the GetFirst, GetLast, GetNext, and GetPrevious methods in a large collection, call GetFirst before calling GetNext on that collection and call GetLast before calling GetPrevious. To ensure that you are always making the calls on the same collection, create an explicit variable that refers to that collection before entering the loop.
Example
This Visual Basic for Applications (VBA) example uses the GetFirst method to locate the first folder in the Contacts folder and then copies the folder to the Test folder. Before running this example, you need to make sure the necessary folders exist in the default Contacts and Inbox folders.
Sub CopyItems()
Dim myNameSpace As Outlook.NameSpace
Dim myDestFolder As Outlook.Folder
Dim mySourceFolder As Outlook.Folder
Dim myNewFolder As Outlook.Folder
Set myNameSpace = Application.GetNamespace("MAPI")
Set myDestFolder = myNameSpace.GetDefaultFolder(olFolderInbox).Folders("Test")
Set mySourceFolder = myNameSpace.GetDefaultFolder(olFolderContacts).Folders.GetFirst
Set myNewFolder = mySourceFolder.CopyTo(myDestFolder)
End Sub
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for