View Single Post
  #6  
Old January 7th 09, 03:38 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Create a new field in Outlook?

Well, it's hard to even supply a code snippet without know more about what
you want. For example is this for contact items or task or appointment items
or what? Is this for every item in a folder or selected items? Be more
detailed in describing your requirements.

At a very basic level assuming you have a macro (VBA Outlook Sub) that has a
ContactItem called oContact and you have an ADO recordset with the field you
want, one named "Foobar" that's a text field and you want to add that
property from the recordset to the oContact item, that would look like this:

' oRST is an ADOB.Recordset already instantiated and filled

Dim oProp As Outlook.UserProperty
Set oProp = oContact.UserProperties("Foobar")
If (oProp Is Nothing) Then
Set oProp = oContact.UserProperties.Add("Foobar", olText, True)
End If
oProp.Value = oRST.Fields("Foobar")
oContact.Save

Of course a DAO recordset would be slightly different, and that snippet
doesn't cover selecting the items to update, getting the recordset and so
on.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Robby" wrote in message
...
hello Ken,

I used to do alot of VBA.... 4 years ago. Unfortunately, its sort of
forgotten!

I simply need to map and import a new field from my Access tables. I was
hoping for a one or two line snippet sample of code in VBA coded in a
macro.
From the little that I remember about VBA, I am sure it isn't that
complicated.

In one post a felow said to use:

MailItem.UserProperties

But how, what procedures.... do I create a macro in outlook and so forth
?

The only reason I wanted to do this is so I can bring in a feild from
Access
to Outlook and then allow synchronization with a Blackberry.

If anyone can gracefully post a simple sample that allows Outlook to
import
a new field, I would really appreciate it.


--
Best regards
Roberto


Ads