This Visual Basic for Applications example returns the second MailItem object in the default Inbox folder. It assumes that at least two MailItem objects already exist.
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
myNameSpace.GetDefaultFolder(olFolderInbox)
Set mySecondItem = myFolder.Items.Item(2)
This Visual Basic for Applications example returns the "Forward" action from the Actions collection.
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem
Set myAction = myItem.Actions.Item("Forward")
This example returns a MAPIFolder object from a Folders collection.
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolders = myNameSpace.Folders
Set myFolder = myFolders.Item("Public Folder")
This Visual Basic for Applications example also returns a MAPIFolder object from a Folders collection.
Set myOlApp = CreateObject("Outlook.Application")
Set myFolders = _
myOlApp.ActiveExplorer.CurrentFolder.Folders
Set myFolder = myFolders.Item("Project X")
This Visual Basic for Applications example creates a contact, returns its empty Pages collection, adds three custom pages and then returns the first custom page from the collection.
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
Set myPages = myItem.GetInspector.ModifiedFormPages
myPages.Add "One"
myPages.Add "Two"
myPages.Add "Three"
Set myPage = myPages.Item("One")
This Visual Basic for Applications example creates a mail message, adds four Recipient objects, then returns the third recipient from the newly-created Recipients collection and sets it as a BCC recipient.
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipients = myItem.Recipients
myRecipients.Add("Rich Andrews")
myRecipients.Add("Robin Hjellin")
myRecipients.Add("Meng Phua")
myRecipients.Add("Kim Yoshida")
myRecipients.Item(3) = olBCC
This Visual Basic for Applications example returns the "Total Cost" user property from the "My Order Form" UserProperties collection.
Set myOlApp = CreateObject("Outlook.Application")
Set myItems = myOlApp.ActiveExplorer.CurrentItem.Items
Set myItem = myItems.Add("My Order Form")
Set myProperties = myItem.UserProperties
Set myProperty = myProperties.Item("Total Cost")