HOW TO:將項目加入至 Outlook 連絡人
更新:2007 年 11 月
適用於 |
---|
本主題中的資訊僅適用於指定的 Visual Studio Tools for Office 專案和 Microsoft Office 版本。 專案類型
Microsoft Office 版本
如需詳細資訊,請參閱依應用程式和專案類型提供的功能。 |
這個範例會建立新的連絡人並將資料輸入新的連絡人。
範例
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.");
}
}