Freigeben über


Gewusst wie: Hinzufügen eines Eintrags zu Outlook-Kontakten

Aktualisiert: November 2007

Betrifft

Die Informationen in diesem Thema gelten nur für die angegebenen Visual Studio Tools for Office-Projekte und Versionen von Microsoft Office.

Projekttyp

  • Projekte auf Anwendungsebene

Microsoft Office-Version

  • Outlook 2003

  • Outlook 2007

Weitere Informationen hierzu finden Sie unter Verfügbare Features nach Anwendung und Projekttyp.

In diesem Beispiel wird ein neuer Kontakt erstellt, und es werden dem neuen Kontakt Daten hinzugefügt.

Beispiel

Private Sub AddContact()
    Dim newContact As Outlook.ContactItem = Me.Application.CreateItem(Outlook. _
        OlItemType.olContactItem)
    Try
        With newContact
            .FirstName = "Jo"
            .LastName = "Berry"
            .Email1Address = "somebody@example.com"
            .CustomerID = "123456"
            .PrimaryTelephoneNumber = "(425)555-0111"
            .MailingAddressStreet = "123 Main St."
            .MailingAddressCity = "Redmond"
            .MailingAddressState = "WA"
            .Save()
            .Display(True)
        End With
    Catch
        MessageBox.Show("The new contact was not saved.")
    End Try
End Sub
 private void AddContact()
{
    Outlook.ContactItem newContact = (Outlook.ContactItem)
        this.Application.CreateItem(Outlook.OlItemType.olContactItem);
    try
    {
        newContact.FirstName = "Jo";
        newContact.LastName = "Berry";
        newContact.Email1Address = "somebody@example.com";
        newContact.CustomerID = "123456";
        newContact.PrimaryTelephoneNumber = "(425)555-0111";
        newContact.MailingAddressStreet = "123 Main St.";
        newContact.MailingAddressCity = "Redmond";
        newContact.MailingAddressState = "WA";
        newContact.Save();
        newContact.Display(true);
    }
    catch 
    {
        MessageBox.Show("The new contact was not saved.");
    }
}

Siehe auch

Aufgaben

Gewusst wie: Erstellen von Terminen

Gewusst wie: Zugreifen auf Outlook-Kontakte

Gewusst wie: Suche nach einer E-Mail-Adresse in Kontakte

Konzepte

Arbeiten mit Kontaktelementen