Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
To create a new item, use the CreateItem method of the Application object. This method returns an object that you can then use to work with the item.
The following Microsoft Visual Basic for Applications example shows how to create a mail message, add text to its subject and body, and display it. To use this sample, create a command button named Command1 on a form.
Private Sub Command1_Click()
Dim myOLItem As Outlook.MailItem
Set myOLItem = Application.CreateItem(olMailItem)
With myOLItem
.Subject = "Sample item"
.Body = "This is a sample message."
End With
myOLItem.Display
End Sub
The following example shows how to perform the same task using VBScript in a form.
Sub CommandButton1_Click()
Set myOLItem = Application.CreateItem(0)
myOLItem.Subject = "Sample item"
myOLItem.Body = "This is a sample message."
myOLItem.Display
End Sub
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.