string strQuery = "[FileAs] = 'Wide World Importers'";
Outlook.ContactItem accountItem = (Outlook.ContactItem)accountsFolder.Items.Find(strQuery);
if (accountItem != null)
{
accountItem.BusinessAddressCity = "New City Address";
accountItem.BusinessAddressState = "New Address State";
accountItem.BusinessAddressStreet = "New Address Street";
accountItem.Save();
}
else
{
Console.WriteLine("Account not found");
}
}
Sub EditAccount()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim bcmRootFolder As Outlook.Folder
Dim olFolders As Outlook.Folders
Dim bcmAccountsFldr As Outlook.Folder
Dim existAcct As Outlook.ContactItem
Set olApp = CreateObject("Outlook.Application")
Set objNS = olApp.GetNamespace("MAPI")
Set olFolders = objNS.Session.Folders
Set bcmRootFolder = olFolders("Business Contact Manager")
Set bcmAccountsFldr = bcmRootFolder.Folders("Accounts")
Set existAcct = bcmAccountsFldr.Items.Find("[FileAs] = 'Wide World'")
If Not TypeName(existAcct) = "Nothing" Then
existAcct.BusinessAddressCity = "New City Address"
existAcct.BusinessAddressState = "New Address State"
existAcct.BusinessAddressStreet = "New Address Street"
existAcct.Save
Else
MsgBox ("No account found with Full Name Wide World Importers")
End If
Set existAcct = Nothing
Set bcmAccountsFldr = Nothing
Set olFolders = Nothing
Set bcmRootFolder = Nothing
Set objNS = Nothing
Set olApp = Nothing