B
Bernhard Schmidt
Hi,
I'm using the Business Contact Manager with Outlook 2007, but
unfortunately it doesn't support listboxes with multiple selection, so I
added my own form with a new itemproperty for my business contacts. When
I want to send out a marketing campaign, I cannot access this property
in the filter, so I created an VSTO Add-In for Word 2007, which imports
the wanted business contacts and adds it to the recipient list.
This works quite well, but for some reason I cannot access the custom
fields from word, it just doesn't find them. The interesting thing is,
when I open a business contact in Outlook, and run the mailmerge add-in
in Word, it does find the custom property of this one contact!
Any idea why?
I go through all contact items, but even if I iterate all
ItemProperties, my testproperty is only shown, if the specific business
contact is opened in Outlook...
Code:
-----------------
Outlook.Application olApp = new
Microsoft.Office.Interop.Outlook.Application();
Outlook.NameSpace olNameSpace = olApp.GetNamespace("MAPI");
Outlook.Folders folders = olNameSpace.Session.Folders;
Outlook.MAPIFolder bcmRootFolder = folders["Business Contact Manager"];
Outlook.MAPIFolder bcmContactFolder = null;
// iterate all folders, since german umlauts are not allowed in index
IEnumerator folderEnum = bcmRootFolder.Folders.GetEnumerator();
while (folderEnum.MoveNext())
{
Outlook.MAPIFolder folder =
(Outlook.MAPIFolder)folderEnum.Current;
if (folder.Name == "Geschäftskontakte")
{
bcmContactFolder = folder;
break;
}
}
[...]
IEnumerator contactEnum = bcmContactFolder.Items.GetEnumerator();
while (contactEnum.MoveNext())
{
Outlook.ContactItem bcmContact =
(contactEnum.Current as Outlook.ContactItem);
Outlook.UserProperty prop1 = bcmContact.UserProperties.Find("mumu",
trueObj);
Outlook.UserProperty prop2 = bcmContact.UserProperties["mumu"];
Outlook.ItemProperty prop3 = bcmContact.ItemProperties["mumu"];
if (prop1 != null)
MessageBox.Show("prop1: " + prop1.Value.ToString());
if (prop2 != null)
MessageBox.Show("prop2: " + prop2.Value.ToString());
if (prop3 != null)
MessageBox.Show("prop3: " + prop3.Value.ToString());
}
I'm using the Business Contact Manager with Outlook 2007, but
unfortunately it doesn't support listboxes with multiple selection, so I
added my own form with a new itemproperty for my business contacts. When
I want to send out a marketing campaign, I cannot access this property
in the filter, so I created an VSTO Add-In for Word 2007, which imports
the wanted business contacts and adds it to the recipient list.
This works quite well, but for some reason I cannot access the custom
fields from word, it just doesn't find them. The interesting thing is,
when I open a business contact in Outlook, and run the mailmerge add-in
in Word, it does find the custom property of this one contact!
Any idea why?
I go through all contact items, but even if I iterate all
ItemProperties, my testproperty is only shown, if the specific business
contact is opened in Outlook...
Code:
-----------------
Outlook.Application olApp = new
Microsoft.Office.Interop.Outlook.Application();
Outlook.NameSpace olNameSpace = olApp.GetNamespace("MAPI");
Outlook.Folders folders = olNameSpace.Session.Folders;
Outlook.MAPIFolder bcmRootFolder = folders["Business Contact Manager"];
Outlook.MAPIFolder bcmContactFolder = null;
// iterate all folders, since german umlauts are not allowed in index
IEnumerator folderEnum = bcmRootFolder.Folders.GetEnumerator();
while (folderEnum.MoveNext())
{
Outlook.MAPIFolder folder =
(Outlook.MAPIFolder)folderEnum.Current;
if (folder.Name == "Geschäftskontakte")
{
bcmContactFolder = folder;
break;
}
}
[...]
IEnumerator contactEnum = bcmContactFolder.Items.GetEnumerator();
while (contactEnum.MoveNext())
{
Outlook.ContactItem bcmContact =
(contactEnum.Current as Outlook.ContactItem);
Outlook.UserProperty prop1 = bcmContact.UserProperties.Find("mumu",
trueObj);
Outlook.UserProperty prop2 = bcmContact.UserProperties["mumu"];
Outlook.ItemProperty prop3 = bcmContact.ItemProperties["mumu"];
if (prop1 != null)
MessageBox.Show("prop1: " + prop1.Value.ToString());
if (prop2 != null)
MessageBox.Show("prop2: " + prop2.Value.ToString());
if (prop3 != null)
MessageBox.Show("prop3: " + prop3.Value.ToString());
}