如何:向 Outlook 联系人添加项

更新:2007 年 11 月

适用对象

本主题中的信息仅适用于指定的 Visual Studio Tools for Office 项目和 Microsoft Office 版本。

项目类型

  • 应用程序级项目

Microsoft Office 版本

  • Outlook 2003

  • Outlook 2007

有关更多信息,请参见按应用程序和项目类型提供的功能

此示例创建新联系人并在新建联系人中输入数据。

示例

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.");
    }
}

请参见

任务

如何:创建约会

如何:访问 Outlook 联系人

如何:在联系人中搜索电子邮件地址

概念

使用联系人项