Subject Property

Microsoft Outlook Visual Basic

Subject Property

       

Returns or sets a String indicating the subject for the Microsoft Outlook item. This property corresponds to the MAPI property PR_SUBJECT. The Subject property is the default property for Outlook items. Read/write.

Note For a NoteItem object, the Subject property is a read-only String that is calculated from the body text of the note.

expression.Subject

expression   Required. An expression that returns one of the objects in the Applies To list.

Example

This Visual Basic for Applications example creates a mail message, sets the Subject to "Speeches", uses the Copy method to copy it, then moves the copy into a newly-created mail folder named "Saved Mail" within the Tasks folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
Set myNewFolder = myFolder.Folders.Add("Saved Mail", olFolderDrafts)
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Subject = "Speeches"
Set myCopiedItem = myItem.Copy
myCopiedItem.Move myNewFolder

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNamespace = Application.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(6)
Set myNewFolder = myFolder.Folders.Add("Saved Mail", 16)
Set myItem = Application.CreateItem(0)
myItem.Subject = "Speeches"
Set myCopiedItem = myItem.Copy
myCopiedItem.Move myNewFolder