Microsoft Office Tutorials and References
In Depth Information
Creating a Ribbon menu for Outlook 2007
Outlook.MAPIFolder PacktContactFolder = Application.Session.
GetDefaultFolder(Outlook.OlDefaultFolders.
olFolderContacts);
// Accessing the Contact data items through Outlook item object
Outlook.Items PacktContactItems = PacktContactFolder.Items.
Restrict("[MessageClass]='IPM.Contact'");
// To read the data one by one from the datatable
foreach (System.Data.DataRow PacktDataRow in PacktDataTable.
Rows)
{
// Check if the current contact item exists in Outlook or not.
Outlook.ContactItem PacktExistingContact = (Outlook.
ContactItem)PacktContactItems.Find("[Email1Address] =
'" + PacktDataRow["Email"] + "'");
// If it exists, then delete
if (PacktExistingContact != null)
{
PacktExistingContact.Delete();
}
else
{
// Create a new contact object and update with data
from database
Outlook.ContactItem PacktAddContact = Application.
CreateItem(Outlook.OlItemType.olContactItem) as
Outlook.ContactItem;
// Assign the value from datarow value
PacktAddContact.FirstName = PacktDataRow["FirstName"].
ToString();
PacktAddContact.Email1Address = PacktDataRow["Email"].
ToString();
PacktAddContact.CompanyName = PacktDataRow["Company"].
ToString();
// Save the assigned values as contact
PacktAddContact.Save();
}
}
}
 
Search JabSto ::




Custom Search