Freigeben über


Programmgesteuertes Erstellen eines E-Mail-Elements

In diesem Beispiel wird eine E-Mail-Nachricht in Microsoft Office Outlook erstellt.

Gilt für: Die Informationen in diesem Thema gelten für VSTO-Add-In-Projekte für Outlook. Weitere Informationen finden Sie unter features available by Office-App lication and project type.

Beispiel

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    CreateMailItem();
}
       
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);
}