Open specific outlook contact item from Access

C

Chris O''''Neill

Btw, do you happen to have any sample Access code for opening Outlook to a
specific contact item? I have the code finished to create an item if one
doesn't exist, but I really want to do this:

If contact item exists then
load contact item and let user edit it if they want '<-- This is
what I need
Else
create a new contact item ' <--- I have this code done
End If

I'm told that I need to store the contact item ID and parent store ID and
use that in the Namespace,GetItemfromID method. So far, I have this code in
my "create a contact item" routine to grab the entry ID and parent store ID:

With objContact
(code to create Outlook contact item)
.save
Me.OutlookEntryID = .EntryID
Me.OutlookParentStoreID = .Parent.StoreID
End With

When this code runs, I get nothing ("") in Me.OutlookEntryID and a *really*
long number in Me.OutlookParentStoreID. So, I *think* I've got the parent
store ID but it looks like I'm not getting the contact item's entry ID. Am I
doing something wrong?

Also, once I've got these ID's (and have stored them in the contact's record
in my Access database, how do I use Namespace,GetItemfromID to call up the
contact record?

Any help and/or code snippets would be *really* helpful! Thanks, in advance!

Regards, Chris
 
C

Chris O''''Neill

Update:

I did some searching and found code that helped me create a routine that I
*think* will find and display the contact item. Now, all I need is to figure
out why this section of code isn't grabbing the contact EntryID:

Dim objOutLook As Outlook.Application
Dim objContact As Outlook.ContactItem
Dim nmsOutlookNameSpace As Outlook.NameSpace

Set objOutLook = CreateObject("Outlook.application")
Set nmsOutlookNameSpace = objOutLook.GetNamespace("MAPI")
Set objContact =
nmsOutlookNameSpace.GetItemFromID(Me.txtOutlookContactID,
Me.txtOutlookContactParentID)

With objContact
(code to create Outlook contact item is here)
.save
Me.OutlookEntryID = .EntryID
Me.OutlookParentStoreID = .Parent.StoreID
End With

objOutlook.Quit
Set objOutLook = Nothing
Set objContact = Nothing
Set nmsOutlookNameSpace = Nothing

When this code runs, I get nothing ("") in Me.OutlookEntryID and a *really*
long number in Me.OutlookParentStoreID. So, I *think* I've got the parent
store ID but it looks like I'm not getting the contact item's entry ID. Am I
doing something wrong?

Any help and/or code snippets would be *really* helpful! Thanks, in advance!

Regards, Chris
 
D

dch3

The EntryID and StoreID can change if the item is moved to another folder or
if its parent is moved. In the past, I've created a custom property on the
Outlook Side and set it to the primary ID of the record that I was working
with. I then used the primary ID to locate the item again.

I have sample code that I should be able to post by late tommorrow (sorry
I'm at Comic Con!), however you'll need to rely on the Outlook group.
 
C

Chris O''''Neill

I did (somehow?) manage to get this working, but I would indeed be interested
in your code as you're right that the user might move the contact item. I'll
post a reply in the Outlook VBA Programming forum for you to reply to.

Thanks! Hope you're enjoying the comic convention!

Regards, Chris
 
C

Chris O''''Neill

LOL! I misread your posting and thought you said "reply to the Outlook
group" instead of "rely on the Outlook grou." Silly me!!! :D

Anyway, I'd be grateful for any coding and other help you can provide. I
have asked questions in the Outlook group but, frankly, find this forum more
helpful.

Regards, Chris
 

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