PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Impossible to fill a user-defined field ?

Reply

Impossible to fill a user-defined field ?

 
Thread Tools Rate Thread
Old 16-02-2004, 06:45 AM   #1
Anthony F.
Guest
 
Posts: n/a
Default Impossible to fill a user-defined field ?


Hello,


working on access 2002 to outlook 2002, I try to create
(from Access) a user-defined field (named "CodeContactInOutlook")

The creation seems to work.

But I can't fill this new user-defined field
as it remains empty for all my contacts.
(even though I fill it programmaticaly)

I work in the Contact default folder.

The code is :
------------------------------------------
Sub exportAccessContactsToOutlook()


' set up DAO Objects.
Dim db As DAO.Database
Dim rst As DAO.Recordset

Set rst = CurrentDb.OpenRecordset("Req Transfert Outlook")

' set up Outlook Objects.
Dim olookApp As New Outlook.Application
Dim olookSpace As Outlook.NameSpace
Dim olookFolder As Outlook.MAPIFolder
Dim olookContact As Outlook.ContactItem
Dim olookUserProp As Outlook.UserProperty
Dim colItems As Items

Set olookSpace = olookApp.GetNamespace("MAPI")
Set olookFolder = olookSpace.GetDefaultFolder(olFolderContacts)
Set colItems =
olookApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items

rst.MoveFirst
Do Until rst.EOF
With colItems.Add
Set olookContact =
olookApp.CreateItem(olContactItem)

olookContact.MessageClass = "IPM.Contact"
Set olookUserProp
=olookContact.UserProperties.Add("CodeContactInOutlook", olNumber)

olookUserProp = rst![Code Contact] 'name
in the Access table

.Save
End With
rst.MoveNext
Loop

rst.Close



End Sub
------------------------------------

Thank you
Anthony


  Reply With Quote
Old 16-02-2004, 12:43 PM   #2
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: Impossible to fill a user-defined field ?

Please see my response Friday to your earlier post on this topic.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Anthony F." <adflores@club-internet.fr> wrote in message
news:4030653b$0$6982$7a628cd7@news.club-internet.fr...
> Hello,
>
>
> working on access 2002 to outlook 2002, I try to create
> (from Access) a user-defined field (named "CodeContactInOutlook")
>
> The creation seems to work.
>
> But I can't fill this new user-defined field
> as it remains empty for all my contacts.
> (even though I fill it programmaticaly)
>
> I work in the Contact default folder.
>
> The code is :
> ------------------------------------------
> Sub exportAccessContactsToOutlook()
>
>
> ' set up DAO Objects.
> Dim db As DAO.Database
> Dim rst As DAO.Recordset
>
> Set rst = CurrentDb.OpenRecordset("Req Transfert Outlook")
>
> ' set up Outlook Objects.
> Dim olookApp As New Outlook.Application
> Dim olookSpace As Outlook.NameSpace
> Dim olookFolder As Outlook.MAPIFolder
> Dim olookContact As Outlook.ContactItem
> Dim olookUserProp As Outlook.UserProperty
> Dim colItems As Items
>
> Set olookSpace = olookApp.GetNamespace("MAPI")
> Set olookFolder = olookSpace.GetDefaultFolder(olFolderContacts)
> Set colItems =
> olookApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
>
> rst.MoveFirst
> Do Until rst.EOF
> With colItems.Add
> Set olookContact =
> olookApp.CreateItem(olContactItem)
>
> olookContact.MessageClass = "IPM.Contact"
> Set olookUserProp
> =olookContact.UserProperties.Add("CodeContactInOutlook", olNumber)
>
> olookUserProp = rst![Code Contact]

'name
> in the Access table
>
> .Save
> End With
> rst.MoveNext
> Loop
>
> rst.Close
>
>
>
> End Sub
> ------------------------------------
>
> Thank you
> Anthony
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off