HOW TO:以程式設計方式建立電子郵件項目
這個範例會在 Microsoft Office Outlook 中建立電子郵件訊息。
**適用於:**本主題中的資訊適用於 Outlook 2013 和 Outlook 2010 的應用程式層級專案。如需詳細資訊,請參閱依 Office 應用程式和專案類型提供的功能。
範例
Private Sub CreateMailItem()
Dim mailItem As Outlook.MailItem = _
Me.Application.CreateItem(Outlook.OlItemType.olMailItem)
mailItem.Subject = "This is the subject"
mailItem.To = "someone@example.com"
mailItem.Body = "This is the message."
mailItem.Importance = Outlook.OlImportance.olImportanceLow
mailItem.Display(False)
End Sub
private void CreateMailItem()
{
Outlook.MailItem mailItem = (Outlook.MailItem)
this.Application.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.Subject = "This is the subject";
mailItem.To = "someone@example.com";
mailItem.Body = "This is the message.";
mailItem.Importance = Outlook.OlImportance.olImportanceLow;
mailItem.Display(false);
}