Tuesday, July 8, 2008

Outlook Business Contact Manager (BCM) Custom Import Tool Update #1

This is the heart of my import tool. It doesn't import or create projects but I imagine the process is very similar. Probably instead of the line "Outlook.Folder accounts = (Outlook.Folder)bcmRootFolder.Folders["Accounts"]" you may want to use something like "Outlook.Folder projects = (Outlook.Folder)bcmRootFolder.Folders["projects"]" or whatever the projects folder is named. And then create a Outlook.ContactItem newProject = (Outlook.ContactItem)projects.Items.Add("IPM.Contact.BCM.Project"). Something like that, you may need to play around with it to figure out exactly how to create that project object but once you get it you should be able to set properties on it like I've done with the account object below.




Outlook.ApplicationClass _app = new Outlook.ApplicationClass();
Outlook.Application olApp = (Outlook.Application)_app;
Outlook.NameSpace olNameSpace = _app.GetNamespace("MAPI");
Outlook.Folders folders = olNameSpace.Session.Folders;
Outlook.Folder bcmRootFolder = (Outlook.Folder)folders["Business Contact Manager"];
Outlook.Folder accounts = (Outlook.Folder)bcmRootFolder.Folders["Accounts"];
Outlook.UserProperty userProp;
foreach (StringDictionary account in accountList)
{
Outlook.ContactItem newAccount = (Outlook.ContactItem)accounts.Items.Add("IPM.Contact.BCM.Account");
newAccount.FullName = account["accountname"].Trim();
newAccount.FileAs = account["accountname"].Trim();
newAccount.OfficeLocation = account["officelocation"].Trim();
newAccount.Save();
//populate the account number
if (newAccount.UserProperties["Account Number"] == null)
{
userProp = newAccount.UserProperties.Add("Account Number", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, false, false);
userProp.Value = account["accountnumber"].Trim();
}
//populate the active flag
if (newAccount.UserProperties["Active"] == null)
{
userProp = newAccount.UserProperties.Add("Active", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olYesNo, false, false);
userProp.Value = account["inactive"].Trim();
}
//populate the type of business
if (newAccount.UserProperties["Type of Business"] == null)
{
userProp = newAccount.UserProperties.Add("Type of Business", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, false, false);
userProp.Value = account["contacttypeid"].Trim();
}
//populate the business address
if (account["address2"].Trim() != string.Empty)
{
StringBuilder sbBusinessAddressStreet = new StringBuilder();
sbBusinessAddressStreet.AppendLine(account["address1"].Trim());
sbBusinessAddressStreet.AppendLine(account["address2"].Trim());
newAccount.BusinessAddressStreet = sbBusinessAddressStreet.ToString();
}
else
{
newAccount.BusinessAddressStreet = account["address1"].Trim();
}
newAccount.BusinessAddressCity = account["city"].Trim();
newAccount.BusinessAddressState = account["state"].Trim();
newAccount.BusinessAddressPostalCode = account["zipcode"].Trim();
newAccount.BusinessAddressCountry = account["country"].Trim();
//add phone and fax info
newAccount.BusinessTelephoneNumber = account["companyphone"].Trim();
newAccount.BusinessFaxNumber = account["faxnumber"].Trim();
newAccount.WebPage = account["webpageaddress"].Trim();
//custom user defined field
}

if (newAccount.UserProperties["Business Card On File"] == null)
{
userProp = newAccount.UserProperties.Add("Business Card On File", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olYesNo, false, false);
userProp.Value = account["cardonfile"].Trim();
}
//add other information
newAccount.Body = account["comments"].Trim();
newAccount.Save();

19 comments:

Denny said...

Thanks for taking the time to post your code. I will use it as a guide in writing a custom import into BCM. Much appreciated!

Brad said...

No problem. Hope it helps, if you have any questions let me know I may have an answer or two. There really isn't a lot of BCM development going on out there. I don't plan to do anymore since all the stuff got imported successfully. But I do have an understanding of some of it.

Ryan said...

I'm an experienced .net developer but new to office programming. I'd like to import projects and also look at writing a routine to create associations between contacts, accounts and projects programigically. Sorry for the very basic question, but where does this code go? Is this something I program in Visual Studio, a macro in outlook, etc? I really appriciate your help! Thanks!

Brad said...

I created a simple windows form with a button and on the button click event I ran the code. It could also be done as a console app but should not be run as a macro in outlook.

The winform or console app needs to be run from the same machine that Outlook BCM is installed on and you should also be logged on as the user that needs new projects or contacts.

If you are using a central BCM database, updating the one user on the one machine will then update all subsequent BCM users if they are also connected to the central BCM database.

But the code can be run from probably any client based windows application that you can write. Let me know if you have other questions.

Ryan said...

That helps alot, thanks Brad!

I think I'm going to just connect directly to the source database using ado.net instead of using a list of StringDictionary objects.

I found these articles that explain how to link contacts, account and projects. Might be helpful for somebody.

http://msdn.microsoft.com/en-us/library/bb267920.aspx

http://msdn.microsoft.com/en-us/library/bb267905.aspx

Thanks Brad! You saved me ALOT of time.

Denny said...

Update: I have successfully imported project data into BCM from Access. Thanks again for pointing me in the right direction.

I do have one lingering question, though.

MSDN's BCM Reference, Properties was helpful in listing the various fields (such as Project Status, Project Start Time). However, I wasn't able to find a property (like "Project Comments") for the comments section under the "Details Tab" in BCM. Do you know what that property name is, or how I could find it?

Brad said...

Sorry Denny, I don't have an answer for that one. Did you try something similar to UserProperties["Project Comments"]?

That would be my guess, I'm not familiar with the projects though.


if (newAccount.UserProperties["Project Comments"] == null)
{

userProp = newAccount.UserProperties.Add("Project Comments", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, false, false);
userProp.Value = "these are the comments";
}

Burt Polson said...

Brad, I ran across your blog in my search to figure out how to import data into BCM 2007 as a Business Project. I am a real estate broker and far from knowing what I am doing or how to manipulate code. This is how I am using BCM:
1. Bus. Contacts are clients, which include property owners.
2. Accounts, I don't really have a purpose to use.
3. Opportunities are property listings for sale or lease.
My problem is that I have one property owner (contact) that may own multiple properties. Plus, the property may have multiple tenants (additional Bus. Contacts). From what I can tell the best way for me to set-up my database is to make each property a Bus. Project with the link-to being the property owner and related contacts and business contacts as tenants, brokers representing owner, etc. Now my problem, I have about 2,500 records with about 50 fields that I can import from a csv file, but I can't find any way to import as a Bus. Project. Any advice you can offer would be appreciated.

Brad said...

Burt -

I'm going to have to let you down on my answer. It sounds like the architecture that you want to go with is feasible however there probably isn't any way to import the data to fit that structure without some custom coding. It sounds like a great idea to track all the properties and associated data as business projects. I just don't believe BCM allows the type of import you want to do out-of-the-box. It could be done with a custom import but that would require coding and cost some money. With that said I'd be happy to do that for you if you'd like to go down that path.

Another option would be to post your same question to the Microsoft newsgroup Microsoft.Public.Outlook.BCM however it is unlikely you'll get the answer you're looking for.

Sorry I don't have a good answer but it's most likely not possible to do without some development costs.

Idonea said...

Hi Brad...If you still can offer dvp to import to BCM or other customizations, I may be interested. I see you masterize the issue and can do the mandatory research to solve any issue.
How can we get in touch to know more about your offer?

Brad said...

Sorry, I can't offer development at this time, I have too much personal stuff going on right now to fit it in between my job and personal life. Brad

Anonymous said...

[url=http://www.ganar-dinero-ya.com][img]http://www.ganar-dinero-ya.com/ganardinero.jpg[/img][/url]
[b]Una gran guia de ganar dinero[/b]
Nosotros hemos encontrado la mejor pagina web en internet de como ganar dinero desde casa. Como nos ha sido de utilidad a nosotros, tambien les puede ser de interes para ustedes. No son solo formas de ganar dinero con su pagina web, hay todo tipo de formas para ganar dinero en internet...
[b][url=http://www.ganar-dinero-ya.com][img]http://www.ganar-dinero-ya.com/dinero.jpg[/img][/url]Te recomendamos entrar a [url=http://www.ganar-dinero-ya.com/]Ganar-dinero-ya.com[/url][url=http://www.ganar-dinero-ya.com][img]http://www.ganar-dinero-ya.com/dinero.jpg[/img][/url][/b]

Alexis said...

My grandfather learnt about emails few time ago. And consequently one day he mared my personal data. I started solving this situation and came to the conclusion to use one forum. I was quite right and the thing which I had been found there might be usable for this proposition as well - fix outlook 2000.

Anonymous said...

Hey! I understand this is somewhat off-topic but I had to ask.
Does running a well-established blog like yours
take a lot of work? I am brand new to running a blog however I do
write in my journal daily. I'd like to start a blog so I can share my personal experience and thoughts online. Please let me know if you have any kind of recommendations or tips for new aspiring bloggers. Thankyou!

Also visit my site; www.sveaskolan.se

Anonymous said...

Wanted detailed info. Much appreciated!

Also visit my web page :: http://hostye.com/

Anonymous said...

It's truly a great and useful piece of information. I am satisfied that you shared this helpful info with us. Please stay us informed in this way. Thank you for sharing.

Feel free to visit my web blog - ,cheap costume earring jewelry

Anonymous said...

If you wish for to get much from this post then you have to apply such strategies to your won
website.

Take a look at my weblog hultquist jewellery london

Anonymous said...

Amazing things here. I am very satisfied to look your
article. Thanks so much and I'm having a look ahead to touch you. Will you please drop me a mail?

My homepage ... pilgrim jewellery dublin (http://ali2s3nhbo.jigsy.com/entries/general/design6_5)

digital signature Adobe Acrobat said...

A special thanks for this informative post. I definitely learned new stuff here I wasn't aware of !