OVH Cloud OVH Cloud

Outlook Access

4 réponses
Avatar
Robert Parise
Je veux envoyé des informations dans contacts de Outlook. Les contacts sont
situés dans un répertoire public.
J'ai trouvé un bout de programmation qui fonctionne avec les contacts du
répertoire par défaut ( GetDefaultFolder(olFolderContacts).Items). Je
n'arrive a modifier la programmation pour aller dans le répertoire désiré
(EBR Contacts)

Merci

Robert


Dim Cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim colItems As Items
Dim upContactId As UserProperty
Dim strMessage As String
Dim objPublicFolders As Object
Dim objFavoritesFolder As Object
Dim objEBRContacts As Object


Set Cn = CurrentProject.Connection

rst.Open "SELECT * FROM tblContact WHERE dblContactLineID = '" &
Me!cboContactLineID & "' ", Cn, adOpenKeyset, adLockOptimistic

'Get a reference to the Items collection of the contacts folder.
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objPublicFolders = objNameSpace.Folders("Public Folders")
Set objFavoritesFolder = objPublicFolders.Folders("All Public Folders")
Set objEBRContacts = objFavoritesFolder.Folders("EBR Contacts").Items


' Set colItems.objOutlook.GetNamespace("MAPI") _
' GetDefaultFolder(olFolderContacts).Items

' Do Until tblContacts.EOF
If boolCheckName(Nz(rst!strFirstName & " " & rst!strLastName), objNameSpace)
Then
'Use the Add method of Items collection to fill in the
'fields with the data from the table and then save the new
'item.
With objNameSpace.Add
.FullName = Nz(rst!strFirstName & " " & rst!strLastName)
' .BusinessAddressStreet = Nz(rst!Address)
' .BusinessAddressCity = Nz(tblContacts!city)
' .BusinessAddressState = Nz(tblContacts!region)
' .BusinessAddressPostalCode = Nz(tblContacts!PostalCode)
' .BusinessAddressCountry = Nz(tblContacts!country)
' .BusinessTelephoneNumber = Nz(tblContacts!Phone)
' .BusinessFaxNumber = Nz(tblContacts!Fax)
' .CompanyName = Nz(tblContacts!CompanyName)
.JobTitle = Nz("Test")

'Create a custom field.
Set upContactId = .UserProperties. _
Add("ContactID", olText)

upContactId = Nz(rst!dblContactLineID)

.Save
End With
End If
rst.Close
Set rst = Nothing

4 réponses

Avatar
Isabelle Prawitz
Bonjour !
Essaie avec
GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("EBR Contacts")

A+
Isa

"Robert Parise" a écrit dans le message de news:XwtFd.5249$
Je veux envoyé des informations dans contacts de Outlook. Les contacts sont
situés dans un répertoire public.
J'ai trouvé un bout de programmation qui fonctionne avec les contacts du
répertoire par défaut ( GetDefaultFolder(olFolderContacts).Items). Je
n'arrive a modifier la programmation pour aller dans le répertoire désiré
(EBR Contacts)

Merci

Robert


Dim Cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim colItems As Items
Dim upContactId As UserProperty
Dim strMessage As String
Dim objPublicFolders As Object
Dim objFavoritesFolder As Object
Dim objEBRContacts As Object


Set Cn = CurrentProject.Connection

rst.Open "SELECT * FROM tblContact WHERE dblContactLineID = '" &
Me!cboContactLineID & "' ", Cn, adOpenKeyset, adLockOptimistic

'Get a reference to the Items collection of the contacts folder.
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objPublicFolders = objNameSpace.Folders("Public Folders")
Set objFavoritesFolder = objPublicFolders.Folders("All Public Folders")
Set objEBRContacts = objFavoritesFolder.Folders("EBR Contacts").Items


' Set colItems.objOutlook.GetNamespace("MAPI") _
' GetDefaultFolder(olFolderContacts).Items

' Do Until tblContacts.EOF
If boolCheckName(Nz(rst!strFirstName & " " & rst!strLastName), objNameSpace)
Then
'Use the Add method of Items collection to fill in the
'fields with the data from the table and then save the new
'item.
With objNameSpace.Add
.FullName = Nz(rst!strFirstName & " " & rst!strLastName)
' .BusinessAddressStreet = Nz(rst!Address)
' .BusinessAddressCity = Nz(tblContacts!city)
' .BusinessAddressState = Nz(tblContacts!region)
' .BusinessAddressPostalCode = Nz(tblContacts!PostalCode)
' .BusinessAddressCountry = Nz(tblContacts!country)
' .BusinessTelephoneNumber = Nz(tblContacts!Phone)
' .BusinessFaxNumber = Nz(tblContacts!Fax)
' .CompanyName = Nz(tblContacts!CompanyName)
.JobTitle = Nz("Test")

'Create a custom field.
Set upContactId = .UserProperties. _
Add("ContactID", olText)

upContactId = Nz(rst!dblContactLineID)

.Save
End With
End If
rst.Close
Set rst = Nothing




Avatar
Isabelle Prawitz
PS : A ta place je ne typerais pas objEBRContacts avec Object, mais Items !
A+
Isa

"Isabelle Prawitz" a écrit dans le message de news:O2evKpW%
Bonjour !
Essaie avec
GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("EBR Contacts")

A+
Isa

"Robert Parise" a écrit dans le message de news:XwtFd.5249$
Je veux envoyé des informations dans contacts de Outlook. Les contacts sont
situés dans un répertoire public.
J'ai trouvé un bout de programmation qui fonctionne avec les contacts du
répertoire par défaut ( GetDefaultFolder(olFolderContacts).Items). Je
n'arrive a modifier la programmation pour aller dans le répertoire désiré
(EBR Contacts)

Merci

Robert


Dim Cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim colItems As Items
Dim upContactId As UserProperty
Dim strMessage As String
Dim objPublicFolders As Object
Dim objFavoritesFolder As Object
Dim objEBRContacts As Object


Set Cn = CurrentProject.Connection

rst.Open "SELECT * FROM tblContact WHERE dblContactLineID = '" &
Me!cboContactLineID & "' ", Cn, adOpenKeyset, adLockOptimistic

'Get a reference to the Items collection of the contacts folder.
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objPublicFolders = objNameSpace.Folders("Public Folders")
Set objFavoritesFolder = objPublicFolders.Folders("All Public Folders")
Set objEBRContacts = objFavoritesFolder.Folders("EBR Contacts").Items


' Set colItems.objOutlook.GetNamespace("MAPI") _
' GetDefaultFolder(olFolderContacts).Items

' Do Until tblContacts.EOF
If boolCheckName(Nz(rst!strFirstName & " " & rst!strLastName), objNameSpace)
Then
'Use the Add method of Items collection to fill in the
'fields with the data from the table and then save the new
'item.
With objNameSpace.Add
.FullName = Nz(rst!strFirstName & " " & rst!strLastName)
' .BusinessAddressStreet = Nz(rst!Address)
' .BusinessAddressCity = Nz(tblContacts!city)
' .BusinessAddressState = Nz(tblContacts!region)
' .BusinessAddressPostalCode = Nz(tblContacts!PostalCode)
' .BusinessAddressCountry = Nz(tblContacts!country)
' .BusinessTelephoneNumber = Nz(tblContacts!Phone)
' .BusinessFaxNumber = Nz(tblContacts!Fax)
' .CompanyName = Nz(tblContacts!CompanyName)
.JobTitle = Nz("Test")

'Create a custom field.
Set upContactId = .UserProperties. _
Add("ContactID", olText)

upContactId = Nz(rst!dblContactLineID)

.Save
End With
End If
rst.Close
Set rst = Nothing








Avatar
Robert Parise
Je n'y arrive toujours pas
Pourriez-vous corriger le code ci-dessous et me le faire parvenir

Merci

Robert

"Isabelle Prawitz" a écrit dans le message de news:
O2evKpW%
Bonjour !
Essaie avec
GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("EBR Contacts")

A+
Isa

"Robert Parise" a écrit dans le message de
news:XwtFd.5249$
Je veux envoyé des informations dans contacts de Outlook. Les contacts
sont
situés dans un répertoire public.
J'ai trouvé un bout de programmation qui fonctionne avec les contacts du
répertoire par défaut ( GetDefaultFolder(olFolderContacts).Items). Je
n'arrive a modifier la programmation pour aller dans le répertoire désiré
(EBR Contacts)

Merci

Robert


Dim Cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim colItems As Items
Dim upContactId As UserProperty
Dim strMessage As String
Dim objPublicFolders As Object
Dim objFavoritesFolder As Object
Dim objEBRContacts As Object


Set Cn = CurrentProject.Connection

rst.Open "SELECT * FROM tblContact WHERE dblContactLineID = '" &
Me!cboContactLineID & "' ", Cn, adOpenKeyset, adLockOptimistic

'Get a reference to the Items collection of the contacts folder.
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objPublicFolders = objNameSpace.Folders("Public Folders")
Set objFavoritesFolder = objPublicFolders.Folders("All Public Folders")
Set objEBRContacts = objFavoritesFolder.Folders("EBR Contacts").Items


' Set colItems.objOutlook.GetNamespace("MAPI") _
' GetDefaultFolder(olFolderContacts).Items

' Do Until tblContacts.EOF
If boolCheckName(Nz(rst!strFirstName & " " & rst!strLastName),
objNameSpace)
Then
'Use the Add method of Items collection to fill in the
'fields with the data from the table and then save the new
'item.
With objNameSpace.Add
.FullName = Nz(rst!strFirstName & " " & rst!strLastName)
' .BusinessAddressStreet = Nz(rst!Address)
' .BusinessAddressCity = Nz(tblContacts!city)
' .BusinessAddressState = Nz(tblContacts!region)
' .BusinessAddressPostalCode =
Nz(tblContacts!PostalCode)
' .BusinessAddressCountry = Nz(tblContacts!country)
' .BusinessTelephoneNumber = Nz(tblContacts!Phone)
' .BusinessFaxNumber = Nz(tblContacts!Fax)
' .CompanyName = Nz(tblContacts!CompanyName)
.JobTitle = Nz("Test")

'Create a custom field.
Set upContactId = .UserProperties. _
Add("ContactID", olText)

upContactId = Nz(rst!dblContactLineID)

.Save
End With
End If
rst.Close
Set rst = Nothing








Avatar
Isabelle Prawitz
Bonjour !
Voici la modif (non testée !)

Dim Cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim colItems As Items
Dim upContactId As UserProperty
Dim strMessage As String
'Dim objPublicFolders As Object
'Dim objFavoritesFolder As Object
Dim objEBRContacts As Items
dim LeDossEBRContacts as MapiFolder


Set Cn = CurrentProject.Connection

rst.Open "SELECT * FROM tblContact WHERE dblContactLineID = '" &
Me!cboContactLineID & "' ", Cn, adOpenKeyset, adLockOptimistic

'Get a reference to the Items collection of the contacts folder.
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set LeDossEBRContacts = objNameSpace.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("EBR Contacts")

Set objEBRContacts = objFavoritesFolder.Folders("EBR Contacts").Items


' Set colItems.objOutlook.GetNamespace("MAPI") _
' GetDefaultFolder(olFolderContacts).Items

' Do Until tblContacts.EOF
If boolCheckName(Nz(rst!strFirstName & " " & rst!strLastName), objNameSpace) ' je ne comprends pas ce test !!!
Then
'Use the Add method of Items collection to fill in the
'fields with the data from the table and then save the new
'item.
With objEBRContacts.Add
.FullName = Nz(rst!strFirstName & " " & rst!strLastName)
' .BusinessAddressStreet = Nz(rst!Address)
' .BusinessAddressCity = Nz(tblContacts!city)
' .BusinessAddressState = Nz(tblContacts!region)
' .BusinessAddressPostalCode = Nz(tblContacts!PostalCode)
' .BusinessAddressCountry = Nz(tblContacts!country)
' .BusinessTelephoneNumber = Nz(tblContacts!Phone)
' .BusinessFaxNumber = Nz(tblContacts!Fax)
' .CompanyName = Nz(tblContacts!CompanyName)
.JobTitle = Nz("Test")

'Create a custom field.
Set upContactId = .UserProperties. _
Add("ContactID", olText)

upContactId = Nz(rst!dblContactLineID)

.Save
End With
End If
rst.Close
Set rst = Nothing

Si le test au dessus permet de vérifier que le contact n'existe pas déjà, et que le 2e paramètre correspond aux items du
dossier EBR Contacts, à la place de objNameSpace, il faut objEBRContacts !
A+
Isa


"Robert Parise" a écrit dans le message de news:BiGFd.8547$
Je n'y arrive toujours pas
Pourriez-vous corriger le code ci-dessous et me le faire parvenir

Merci

Robert

"Isabelle Prawitz" a écrit dans le message de news:
O2evKpW%
Bonjour !
Essaie avec
GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("EBR Contacts")

A+
Isa

"Robert Parise" a écrit dans le message de
news:XwtFd.5249$
Je veux envoyé des informations dans contacts de Outlook. Les contacts
sont
situés dans un répertoire public.
J'ai trouvé un bout de programmation qui fonctionne avec les contacts du
répertoire par défaut ( GetDefaultFolder(olFolderContacts).Items). Je
n'arrive a modifier la programmation pour aller dans le répertoire désiré
(EBR Contacts)

Merci

Robert


Dim Cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim colItems As Items
Dim upContactId As UserProperty
Dim strMessage As String
Dim objPublicFolders As Object
Dim objFavoritesFolder As Object
Dim objEBRContacts As Object


Set Cn = CurrentProject.Connection

rst.Open "SELECT * FROM tblContact WHERE dblContactLineID = '" &
Me!cboContactLineID & "' ", Cn, adOpenKeyset, adLockOptimistic

'Get a reference to the Items collection of the contacts folder.
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objPublicFolders = objNameSpace.Folders("Public Folders")
Set objFavoritesFolder = objPublicFolders.Folders("All Public Folders")
Set objEBRContacts = objFavoritesFolder.Folders("EBR Contacts").Items


' Set colItems.objOutlook.GetNamespace("MAPI") _
' GetDefaultFolder(olFolderContacts).Items

' Do Until tblContacts.EOF
If boolCheckName(Nz(rst!strFirstName & " " & rst!strLastName),
objNameSpace)
Then
'Use the Add method of Items collection to fill in the
'fields with the data from the table and then save the new
'item.
With objNameSpace.Add
.FullName = Nz(rst!strFirstName & " " & rst!strLastName)
' .BusinessAddressStreet = Nz(rst!Address)
' .BusinessAddressCity = Nz(tblContacts!city)
' .BusinessAddressState = Nz(tblContacts!region)
' .BusinessAddressPostalCode > >> Nz(tblContacts!PostalCode)
' .BusinessAddressCountry = Nz(tblContacts!country)
' .BusinessTelephoneNumber = Nz(tblContacts!Phone)
' .BusinessFaxNumber = Nz(tblContacts!Fax)
' .CompanyName = Nz(tblContacts!CompanyName)
.JobTitle = Nz("Test")

'Create a custom field.
Set upContactId = .UserProperties. _
Add("ContactID", olText)

upContactId = Nz(rst!dblContactLineID)

.Save
End With
End If
rst.Close
Set rst = Nothing