Linked Account with VBA

R

Reinfried

Where can I get the Linked account-value (not the Field CompanyName) in a
BusinessContact with VBA? Is this the "ParentDisplayName" anh how can I get
it?

Sub SelectBusinessContact()
Dim olApp As Outlook.Application
Dim objNS As Outlook.Namespace
Dim bcmRootFolder As Outlook.Folder
Dim olFolders As Outlook.Folders
Dim bcmContactsFldr As Outlook.Folder
Dim existContact 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 bcmContactsFldr = bcmRootFolder.Folders("Geschäftskontakte")
Dim strLastName
Dim strCompanyName
strLastName = "Gates"
strCompanyName = "Microsoft"
Set existContact = bcmContactsFldr.Items.Find("[LastName] = " & "'" &
strLastName & "'" & " AND [CompanyName] = '" & strCompanyName & "'" & "")
If Not TypeName(existContact) = "Nothing" Then
MsgBox existContact.FullName & vbCrLf & existContact.BusinessAddress _
& vbCrLf & "Tel.Nr.Büro: " & existContact.BusinessTelephoneNumber _
& vbCrLf & "Fax.Nr.Büro: " & existContact.BusinessFaxNumber _
& vbCrLf & "Mobil: " & existContact.MobileTelephoneNumber _
& vbCrLf & "Firma: " & existContact.CompanyName
Else
MsgBox ("Could not find the Business Contact")
End If
Set existContact = Nothing
Set bcmContactsFldr = Nothing
Set bcmRootFolder = Nothing
Set olFolders = Nothing
Set objNS = Nothing
Set olApp = Nothing
End Sub

Many Thanks

Reinfried
 
L

Luther

Where can I get the Linked account-value (not the Field CompanyName) in a
BusinessContact with VBA?  Is this the "ParentDisplayName" anh how can I get
it?

Sub SelectBusinessContact()
   Dim olApp As Outlook.Application
   Dim objNS As Outlook.Namespace
   Dim bcmRootFolder As Outlook.Folder
   Dim olFolders As Outlook.Folders
   Dim bcmContactsFldr As Outlook.Folder
   Dim existContact 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 bcmContactsFldr = bcmRootFolder.Folders("Geschäftskontakte")
   Dim strLastName
   Dim strCompanyName
   strLastName = "Gates"
   strCompanyName = "Microsoft"
   Set existContact = bcmContactsFldr.Items.Find("[LastName] = " & "'" &
strLastName & "'" & " AND [CompanyName] = '" & strCompanyName & "'" & "")
      If Not TypeName(existContact) = "Nothing" Then
      MsgBox existContact.FullName & vbCrLf & existContact.BusinessAddress _
      & vbCrLf & "Tel.Nr.Büro: " & existContact.BusinessTelephoneNumber _
      & vbCrLf & "Fax.Nr.Büro: " & existContact.BusinessFaxNumber_
      & vbCrLf & "Mobil: " & existContact.MobileTelephoneNumber _
      & vbCrLf & "Firma: " & existContact.CompanyName
   Else
      MsgBox ("Could not find the Business Contact")
   End If
   Set existContact = Nothing
   Set bcmContactsFldr = Nothing
   Set bcmRootFolder = Nothing
   Set olFolders = Nothing
   Set objNS = Nothing
   Set olApp = Nothing
End Sub

Many Thanks

Reinfried

A Business Contact's parent Account is in the "Parent Entity EntryID"
field. That values is a GUID. The "Parent Account Name" field should
have the name of the Account.
 
R

Reinfried

Luther said:
Where can I get the Linked account-value (not the Field CompanyName) in a
BusinessContact with VBA? Is this the "ParentDisplayName" anh how can I get
it?

Sub SelectBusinessContact()
Dim olApp As Outlook.Application
Dim objNS As Outlook.Namespace
Dim bcmRootFolder As Outlook.Folder
Dim olFolders As Outlook.Folders
Dim bcmContactsFldr As Outlook.Folder
Dim existContact 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 bcmContactsFldr = bcmRootFolder.Folders("Geschäftskontakte")
Dim strLastName
Dim strCompanyName
strLastName = "Gates"
strCompanyName = "Microsoft"
Set existContact = bcmContactsFldr.Items.Find("[LastName] = " & "'" &
strLastName & "'" & " AND [CompanyName] = '" & strCompanyName & "'" & "")
If Not TypeName(existContact) = "Nothing" Then
MsgBox existContact.FullName & vbCrLf & existContact.BusinessAddress _
& vbCrLf & "Tel.Nr.Büro: " & existContact.BusinessTelephoneNumber _
& vbCrLf & "Fax.Nr.Büro: " & existContact.BusinessFaxNumber _
& vbCrLf & "Mobil: " & existContact.MobileTelephoneNumber _
& vbCrLf & "Firma: " & existContact.CompanyName
Else
MsgBox ("Could not find the Business Contact")
End If
Set existContact = Nothing
Set bcmContactsFldr = Nothing
Set bcmRootFolder = Nothing
Set olFolders = Nothing
Set objNS = Nothing
Set olApp = Nothing
End Sub

Many Thanks

Reinfried

A Business Contact's parent Account is in the "Parent Entity EntryID"
field. That values is a GUID. The "Parent Account Name" field should
have the name of the Account.

Hallo Luther,
many Thanks for the answer.

With
existContact.UserProperties("Parent Entity EntryID") i get th GUI, but with
existContact.UserProperties("Parent Account Name") or with
existContact.UserProperties("ParentAccountName") there is an error.

Reinfried
 
L

Luther

Luther said:
Where can I get the Linked account-value (not the Field CompanyName) in a
BusinessContact with VBA?  Is this the "ParentDisplayName" anh how can I get
it?
Sub SelectBusinessContact()
   Dim olApp As Outlook.Application
   Dim objNS As Outlook.Namespace
   Dim bcmRootFolder As Outlook.Folder
   Dim olFolders As Outlook.Folders
   Dim bcmContactsFldr As Outlook.Folder
   Dim existContact 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 bcmContactsFldr = bcmRootFolder.Folders("Geschäftskontakte")
   Dim strLastName
   Dim strCompanyName
   strLastName = "Gates"
   strCompanyName = "Microsoft"
   Set existContact = bcmContactsFldr.Items.Find("[LastName] = " & "'" &
strLastName & "'" & " AND [CompanyName] = '" & strCompanyName & "'"& "")
      If Not TypeName(existContact) = "Nothing" Then
      MsgBox existContact.FullName & vbCrLf & existContact.BusinessAddress _
      & vbCrLf & "Tel.Nr.Büro: " & existContact.BusinessTelephoneNumber _
      & vbCrLf & "Fax.Nr.Büro: " & existContact.BusinessFaxNumber _
      & vbCrLf & "Mobil: " & existContact.MobileTelephoneNumber_
      & vbCrLf & "Firma: " & existContact.CompanyName
   Else
      MsgBox ("Could not find the Business Contact")
   End If
   Set existContact = Nothing
   Set bcmContactsFldr = Nothing
   Set bcmRootFolder = Nothing
   Set olFolders = Nothing
   Set objNS = Nothing
   Set olApp = Nothing
End Sub
Many Thanks
Reinfried
A Business Contact's parent Account is in the "Parent Entity EntryID"
field. That values is a GUID. The "Parent Account Name" field should
have the name of the Account.

Hallo Luther,
many Thanks for the answer.

With
existContact.UserProperties("Parent Entity EntryID") i get th GUI, but with
existContact.UserProperties("Parent Account Name") or with
existContact.UserProperties("ParentAccountName") there is an error.

Reinfried- Hide quoted text -

- Show quoted text -

Hmmm, "Parent Account Name" is used in the code in this post from
Clinton.
http://groups.google.com/group/micr...=en&lnk=gst&q=parent+account#aed503ea69c70517

Does that contact have a value in that field when you open the Contact
in a form? If so, perhaps the the form is fetching it from the Account
basedvon the GUID, but that sounds inefficient.

There's a Sql View called something like AccountFullView, select the
contents of that view with a sql query and see what the value of that
field is in the database. That might offer a clue.
 
R

Reinfried

Many Thanks Luther,
i have changed my VBAcode and I use now SQl-Code for my problem:

SELECT PublicAccountsView.FullName, PublicContactsView.LastName,
PublicContactsView.FirstName
FROM PublicAccountsView INNER JOIN
PublicContactsView ON PublicAccountsView.EntryGUID =
PublicContactsView.ParentEntryID
order by PublicAccountsView.FullName, PublicContactsView.LastName,
PublicContactsView.FirstName

Reinfried

Luther said:
Luther said:
On Sep 24, 6:48 am, Reinfried <[email protected]>
wrote:
Where can I get the Linked account-value (not the Field CompanyName) in a
BusinessContact with VBA? Is this the "ParentDisplayName" anh how can I get
it?
Sub SelectBusinessContact()
Dim olApp As Outlook.Application
Dim objNS As Outlook.Namespace
Dim bcmRootFolder As Outlook.Folder
Dim olFolders As Outlook.Folders
Dim bcmContactsFldr As Outlook.Folder
Dim existContact 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 bcmContactsFldr = bcmRootFolder.Folders("Geschäftskontakte")
Dim strLastName
Dim strCompanyName
strLastName = "Gates"
strCompanyName = "Microsoft"
Set existContact = bcmContactsFldr.Items.Find("[LastName] = " & "'" &
strLastName & "'" & " AND [CompanyName] = '" & strCompanyName & "'" & "")
If Not TypeName(existContact) = "Nothing" Then
MsgBox existContact.FullName & vbCrLf & existContact.BusinessAddress _
& vbCrLf & "Tel.Nr.Büro: " & existContact.BusinessTelephoneNumber _
& vbCrLf & "Fax.Nr.Büro: " & existContact.BusinessFaxNumber _
& vbCrLf & "Mobil: " & existContact.MobileTelephoneNumber _
& vbCrLf & "Firma: " & existContact.CompanyName
Else
MsgBox ("Could not find the Business Contact")
End If
Set existContact = Nothing
Set bcmContactsFldr = Nothing
Set bcmRootFolder = Nothing
Set olFolders = Nothing
Set objNS = Nothing
Set olApp = Nothing
End Sub
Many Thanks

A Business Contact's parent Account is in the "Parent Entity EntryID"
field. That values is a GUID. The "Parent Account Name" field should
have the name of the Account.

Hallo Luther,
many Thanks for the answer.

With
existContact.UserProperties("Parent Entity EntryID") i get th GUI, but with
existContact.UserProperties("Parent Account Name") or with
existContact.UserProperties("ParentAccountName") there is an error.

Reinfried- Hide quoted text -

- Show quoted text -

Hmmm, "Parent Account Name" is used in the code in this post from
Clinton.
http://groups.google.com/group/micr...=en&lnk=gst&q=parent+account#aed503ea69c70517

Does that contact have a value in that field when you open the Contact
in a form? If so, perhaps the the form is fetching it from the Account
basedvon the GUID, but that sounds inefficient.

There's a Sql View called something like AccountFullView, select the
contents of that view with a sql query and see what the value of that
field is in the database. That might offer a clue.
 
L

Luther

Many Thanks Luther,
i have changed my VBAcode and I use now SQl-Code for my problem:

SELECT      PublicAccountsView.FullName, PublicContactsView.LastName,
PublicContactsView.FirstName
FROM         PublicAccountsView INNER JOIN
                      PublicContactsView ON PublicAccountsView.EntryGUID =
PublicContactsView.ParentEntryID
order by PublicAccountsView.FullName, PublicContactsView.LastName,
PublicContactsView.FirstName

Reinfried



Luther said:
:
On Sep 24, 6:48 am, Reinfried <[email protected]>
wrote:
Where can I get the Linked account-value (not the Field CompanyName) in a
BusinessContact with VBA?  Is this the "ParentDisplayName" anh how can I get
it?
Sub SelectBusinessContact()
   Dim olApp As Outlook.Application
   Dim objNS As Outlook.Namespace
   Dim bcmRootFolder As Outlook.Folder
   Dim olFolders As Outlook.Folders
   Dim bcmContactsFldr As Outlook.Folder
   Dim existContact 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 bcmContactsFldr = bcmRootFolder.Folders("Geschäftskontakte")
   Dim strLastName
   Dim strCompanyName
   strLastName = "Gates"
   strCompanyName = "Microsoft"
   Set existContact = bcmContactsFldr.Items.Find("[LastName] = " & "'" &
strLastName & "'" & " AND [CompanyName] = '" & strCompanyName &"'" & "")
      If Not TypeName(existContact) = "Nothing" Then
      MsgBox existContact.FullName & vbCrLf & existContact.BusinessAddress _
      & vbCrLf & "Tel.Nr.Büro: " & existContact.BusinessTelephoneNumber _
      & vbCrLf & "Fax.Nr.Büro: " & existContact.BusinessFaxNumber _
      & vbCrLf & "Mobil: " & existContact.MobileTelephoneNumber _
      & vbCrLf & "Firma: " & existContact.CompanyName
   Else
      MsgBox ("Could not find the Business Contact")
   End If
   Set existContact = Nothing
   Set bcmContactsFldr = Nothing
   Set bcmRootFolder = Nothing
   Set olFolders = Nothing
   Set objNS = Nothing
   Set olApp = Nothing
End Sub
Many Thanks
Reinfried
A Business Contact's parent Account is in the "Parent Entity EntryID"
field. That values is a GUID. The "Parent Account Name" field should
have the name of the Account.
Hallo Luther,
many Thanks for the answer.
With
existContact.UserProperties("Parent Entity EntryID") i get th GUI, but with
existContact.UserProperties("Parent Account Name") or with
existContact.UserProperties("ParentAccountName") there is an error.
Reinfried- Hide quoted text -
- Show quoted text -
Hmmm, "Parent Account Name" is used in the code in this post from
Clinton.
http://groups.google.com/group/microsoft.public.outlook.bcm/browse_th...
Does that contact have a value in that field when you open the Contact
in a form? If so, perhaps the the form is fetching it from the Account
basedvon the GUID, but that sounds inefficient.
There's a Sql View called something like AccountFullView, select the
contents of that view with a sql query and see what the value of that
field is in the database. That might offer a clue.- Hide quoted text -

- Show quoted text -

They added, and documented, the PublicXxxViews in V3 to give users
direct access to the data, instead of having to figure out the
idiosyncracies
of the Outlook object model. Note that the Public Views are also
updateable.
If you add or update a record in a Public View, BCM will take care of
running
the change through BCM/Outlook the next time BCM runs. That way
Outlook
can update the fullname field if you change the firstname field, and
so on.
 

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