![]()
The NoteItem Object is one of the objects in the Outlook Object Model hierarchy. This series of articles will explore the ways you can automate Notes.
Follow the above links to learn more about the NoteItem Object's methods, properties and events.
Creating Notes in Default Folder
NoteItem Objects may be created in several ways. Application.CreateItem may be used to create a new note in the local default Notes folder.
Function CreateNote() As Outlook.NoteItem Set CreateNote = Outlook.CreateItem(olNoteItem) End Function
Create Notes in any Notes folder
Pass a MAPIFolder object to the following function and it will create and return a new Note in that folder, provided that the folder is of a type that holds Notes.
Function CreateNoteAltFolder(fldr As Outlook.MAPIFolder) As Outlook.NoteItem
If fldr.DefaultItemType = olNoteItem Then
Set CreateNoteAltFolder = fldr.Items.Add(olNoteItem)
End If
End Function
Create Notes in Shared Folder
Creating Notes in a shared folder requires permission to access that folder. Here is a function to create a Note in the specified user's shared Notes folder and return that NoteItem to the calling function. You pass in either a resolved Recipient object or the name of a user whose shared Notes folder you have access to and want to create a Note for.
Function CreateSharedDefaultNote(recip As Variant) As Outlook.NoteItem
Dim olNS As Outlook.NameSpace
Dim fldr As Outlook.MAPIFolder
Dim tempRecip As Outlook.recipient
Select Case TypeName(recip)
Case "Recipient"
' Recipient object already created
Set fldr = olNS.GetSharedDefaultFolder(recip, olFolderNotes)
Case "String"
' create Recipient object
Set olNS = GetNS(GetOutlookApp)
Set tempRecip = olNS.CreateRecipient(recip)
Set fldr = olNS.GetSharedDefaultFolder(tempRecip, olFolderNotes)
End Select
Set CreateSharedDefaultNote = fldr.Items.Add(olNoteItem)
End Function
Function GetNS(ByRef app As Outlook.Application) As Outlook.NameSpace
Set GetNS = app.GetNamespace("MAPI")
End Function
Function GetOutlookApp() As Outlook.Application
' returns reference to native Application object
Set GetOutlookApp = Outlook.Application
End Function
If a Recipient object is passed to the function, the new NoteItem is created directly. If only a name is passed, a temporary Recipient object is created using the Outlook.NameSpace.CreateRecipient Method.