MailItem-Objekt (Outlook)MailItem object (Outlook)
Stellt eine E-Mail-Nachricht dar.Represents a mail message.
BemerkungenRemarks
Verwenden Sie die Methode CreateItem zum Erstellen eines Objekts vom Typ MailItem, das eine neue E-Mail darstellt.Use the CreateItem method to create a MailItem object that represents a new mail message.
Verwenden Sie die Folder. Items -Eigenschaft, um eine Items -Auflistung abzurufen, die die e-Mail-Elemente in einem Ordner darstellt, und die Items. Item (Index)-Methode, wobei Index die Indexnummer einer e-Mail-Nachricht oder ein Wert ist, der für die Übereinstimmung mit dem Default-Eigenschaft einer Nachricht, um ein einzelnes MailItem -Objekt aus dem angegebenen Ordner zurückzugeben.Use the Folder.Items property to obtain an Items collection representing the mail items in a folder, and the Items.Item (index) method, where index is the index number of a mail message or a value used to match the default property of a message, to return a single MailItem object from the specified folder.
BeispielExample
Im folgenden Visual Basic for Applications-Beispiel (VBA) wird eine neue E-Mail erstellt und dargestellt.The following Visual Basic for Applications (VBA) example creates and displays a new mail message.
Sub CreateMail()
Dim myItem As Object
Set myItem = Application.CreateItem(olMailItem)
myItem.Subject = "Mail to myself"
myItem.Display
End Sub
Im folgenden VBA-Beispiel wird der aktuelle Ordner als Postfach festgelegt, und es wird die zweite E-Mail im Ordner angezeigt.The following VBA example sets the current folder as the Inbox and displays the second mail message in the folder. Im Allgemeinen gilt, dass die E-Mails in einem Ordner nicht garantiert in einer bestimmten Reihenfolge vorliegen.In general, the order of mail messages in a folder is not guaranteed to be in a particular order.
Sub DisplayMail()
Dim myItem As Object
Dim myFolder As Folder
Set myNamespace = Application.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
myFolder.Display
Set myItem = myFolder.Items(2)
myItem.Display
End Sub
EreignisseEvents
MethodenMethods
EigenschaftenProperties
Siehe auchSee also
- Senden einer E-Mail-Nachricht mithilfe der SMTP-Adresse eines KontosSend an email given the SMTP address of an account
- Outlook-ObjektmodellreferenzOutlook Object Model reference
Support und FeedbackSupport and feedback
Haben Sie Fragen oder Feedback zu Office VBA oder zu dieser Dokumentation?Have questions or feedback about Office VBA or this documentation? Unter Office VBA-Support und Feedback finden Sie Hilfestellung zu den Möglichkeiten, wie Sie Support erhalten und Feedback abgeben können.Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.