Importing from Access with custom code

B

Brad Covell

I'm currently developing an application that will import account and contact
information into BCM from an Access database. I tried originally to import
using the built-in tool but there are some items like the ability to link
contact information within Access to the account being imported. Along with
some other fields that didn't really map well, so I started on a project to
do a custom import.

I am currently able to import a lot of the information the samples provided
on msdn were great. However, I'm trying to import the Account Number and
Active properties http://msdn2.microsoft.com/en-us/library/bb267853.aspx
But the following doesn't have an AccountNumber property.

Am I missing something or shouldn't the AccountNumber and Active property
work? Is there a way around this?

Thanks
Brad

//account object is a DictionaryEntry that I populated with the Access
database information.

Outlook.ContactItem newAccount =
(Outlook.ContactItem)accounts.Items.Add("IPM.Contact.BCM.Account");

newAccount.FullName = account["accountname"]; //works

newAccount.FileAs = account["accountname"]; //works

newAccount.AccountNumber = account["accountnumber"]; //doesn't like this,
even though it's documented that this should work, same thing for Active

newAccount.Active = true; //fails

newAccount.OfficeLocation = account["officelocation"]; //works
 
L

Luther

I'm currently developing an application that will import account and contact
information into BCM from an Access database. I tried originally to import
using the built-in tool but there are some items like the ability to link
contact information within Access to the account being imported. Along with
some other fields that didn't really map well, so I started on a project to
do a custom import.

I am currently able to import a lot of the information the samples provided
on msdn were great. However, I'm trying to import the Account Number and
Active propertieshttp://msdn2.microsoft.com/en-us/library/bb267853.aspx
But the following doesn't have an AccountNumber property.

Am I missing something or shouldn't the AccountNumber and Active property
work? Is there a way around this?

Thanks
Brad

//account object is a DictionaryEntry that I populated with the Access
database information.

Outlook.ContactItem newAccount =
(Outlook.ContactItem)accounts.Items.Add("IPM.Contact.BCM.Account");

newAccount.FullName = account["accountname"]; //works

newAccount.FileAs = account["accountname"]; //works

newAccount.AccountNumber = account["accountnumber"];  //doesn't like this,
even though it's documented that this should work, same thing for Active

newAccount.Active = true; //fails

newAccount.OfficeLocation = account["officelocation"]; //works

I bet because they're in the ItemProperties array.

Welcome to the Outlook Object Model!
 
B

Brad Covell

Luther,,

I have tried setting newAccount.ItemProperties["Account Number"].Value and
newAccount.ItemProperties["Active"].Value but it throws an exception, object
not set to an instance of an object.

I don't think they are in the ItemProperties array. Is this an issue with
the object model? if so, is there any way around this? Can you confirm this?
The other import code works great it's just these last few properties that
I'm missing because their properties don't seem to be active in the object
model.

I can send my import application if you'd like to see the issue. Is this
something I should open a case for if it is an issue?

Thanks
Brad



I'm currently developing an application that will import account and
contact
information into BCM from an Access database. I tried originally to import
using the built-in tool but there are some items like the ability to link
contact information within Access to the account being imported. Along
with
some other fields that didn't really map well, so I started on a project
to
do a custom import.

I am currently able to import a lot of the information the samples
provided
on msdn were great. However, I'm trying to import the Account Number and
Active propertieshttp://msdn2.microsoft.com/en-us/library/bb267853.aspx
But the following doesn't have an AccountNumber property.

Am I missing something or shouldn't the AccountNumber and Active property
work? Is there a way around this?

Thanks
Brad

//account object is a DictionaryEntry that I populated with the Access
database information.

Outlook.ContactItem newAccount =
(Outlook.ContactItem)accounts.Items.Add("IPM.Contact.BCM.Account");

newAccount.FullName = account["accountname"]; //works

newAccount.FileAs = account["accountname"]; //works

newAccount.AccountNumber = account["accountnumber"]; //doesn't like this,
even though it's documented that this should work, same thing for Active

newAccount.Active = true; //fails

newAccount.OfficeLocation = account["officelocation"]; //works

I bet because they're in the ItemProperties array.

Welcome to the Outlook Object Model!
 
B

Brad Covell

Well I figured it out. Here is the solution. Not that obvious since Account
Number isn't a user created field. I would have expected it to be off of the
newAccount object or in the ItemProperties collection.

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();

}



I'm currently developing an application that will import account and
contact
information into BCM from an Access database. I tried originally to import
using the built-in tool but there are some items like the ability to link
contact information within Access to the account being imported. Along
with
some other fields that didn't really map well, so I started on a project
to
do a custom import.

I am currently able to import a lot of the information the samples
provided
on msdn were great. However, I'm trying to import the Account Number and
Active propertieshttp://msdn2.microsoft.com/en-us/library/bb267853.aspx
But the following doesn't have an AccountNumber property.

Am I missing something or shouldn't the AccountNumber and Active property
work? Is there a way around this?

Thanks
Brad

//account object is a DictionaryEntry that I populated with the Access
database information.

Outlook.ContactItem newAccount =
(Outlook.ContactItem)accounts.Items.Add("IPM.Contact.BCM.Account");

newAccount.FullName = account["accountname"]; //works

newAccount.FileAs = account["accountname"]; //works

newAccount.AccountNumber = account["accountnumber"]; //doesn't like this,
even though it's documented that this should work, same thing for Active

newAccount.Active = true; //fails

newAccount.OfficeLocation = account["officelocation"]; //works

I bet because they're in the ItemProperties array.

Welcome to the Outlook Object Model!
 
L

Luther

Well I figured it out. Here is the solution. Not that obvious since Account
Number isn't a user created field. I would have expected it to be off of the
newAccount object or in the ItemProperties collection.

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();

}

I'm currently developing an application that will import account and
contact
information into BCM from an Access database. I tried originally to import
using the built-in tool but there are some items like the ability to link
contact information within Access to the account being imported. Along
with
some other fields that didn't really map well, so I started on a project
to
do a custom import.
I am currently able to import a lot of the information the samples
provided
on msdn were great. However, I'm trying to import the Account Number and
Active propertieshttp://msdn2.microsoft.com/en-us/library/bb267853.aspx
But the following doesn't have an AccountNumber property.
Am I missing something or shouldn't the AccountNumber and Active property
work? Is there a way around this?

//account object is a DictionaryEntry that I populated with the Access
database information.
Outlook.ContactItem newAccount =
(Outlook.ContactItem)accounts.Items.Add("IPM.Contact.BCM.Account");
newAccount.FullName = account["accountname"]; //works
newAccount.FileAs = account["accountname"]; //works
newAccount.AccountNumber = account["accountnumber"]; //doesn't like this,
even though it's documented that this should work, same thing for Active
newAccount.Active = true; //fails
newAccount.OfficeLocation = account["officelocation"]; //works

I bet because they're in the ItemProperties array.

Welcome to the Outlook Object Model!- Hide quoted text -

- Show quoted text -

Good stuff.

I just blogged the VBS code for creating the Active property before
setting its value, so I can find it the next time something like this
comes up.

http://beyng.blogspot.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top