PC Review


Reply
Thread Tools Rate Thread

Create a new field in Outlook?

 
 
Robby
Guest
Posts: n/a
 
      6th Jan 2009
Hello,

Is there any way to create/add a new field in MS Outlook. Basically I just
want to import a field that exists in one of my Access tables to Outlook.

All help appreciated!

--
Best regards
Roberto
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      6th Jan 2009
You can create what's called a UserProperty on items, but the export/import
function won't import custom properties. You would have to write your own
code to do that.

--
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" <(E-Mail Removed)> wrote in message
news:53CF22A5-859C-47EA-BBAA-(E-Mail Removed)...
> Hello,
>
> Is there any way to create/add a new field in MS Outlook. Basically I just
> want to import a field that exists in one of my Access tables to Outlook.
>
> All help appreciated!
>
> --
> Best regards
> Roberto


 
Reply With Quote
 
Robby
Guest
Posts: n/a
 
      6th Jan 2009
I am familiar with C/C++/Win32 programming. Is it very difficult to write my
own code to import a new field in Outlook from access ?


--
Best regards
Roberto


"Ken Slovak - [MVP - Outlook]" wrote:

> You can create what's called a UserProperty on items, but the export/import
> function won't import custom properties. You would have to write your own
> code to do that.
>
> --
> 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" <(E-Mail Removed)> wrote in message
> news:53CF22A5-859C-47EA-BBAA-(E-Mail Removed)...
> > Hello,
> >
> > Is there any way to create/add a new field in MS Outlook. Basically I just
> > want to import a field that exists in one of my Access tables to Outlook.
> >
> > All help appreciated!
> >
> > --
> > Best regards
> > Roberto

>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      6th Jan 2009

Outlook code is completely different than usual Win32 programming, you have
to know the Outlook object model and in this case the Access object model. I
don't do C++ so I couldn't help with that.

You can look at the information and tons of samples at www.outlookcode.com
for Access importing samples, but I'd guess they are all or almost all in
VBA/VB/C#/VB.NET code.

--
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" <(E-Mail Removed)> wrote in message
news:64454B20-CA9B-4DED-A40A-(E-Mail Removed)...
>I am familiar with C/C++/Win32 programming. Is it very difficult to write
>my
> own code to import a new field in Outlook from access ?
>
>
> --
> Best regards
> Roberto


 
Reply With Quote
 
Robby
Guest
Posts: n/a
 
      6th Jan 2009

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


"Ken Slovak - [MVP - Outlook]" wrote:

> Outlook code is completely different than usual Win32 programming, you have
> to know the Outlook object model and in this case the Access object model. I
> don't do C++ so I couldn't help with that.
>
> You can look at the information and tons of samples at www.outlookcode.com
> for Access importing samples, but I'd guess they are all or almost all in
> VBA/VB/C#/VB.NET code.
>
> --
> 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" <(E-Mail Removed)> wrote in message
> news:64454B20-CA9B-4DED-A40A-(E-Mail Removed)...
> >I am familiar with C/C++/Win32 programming. Is it very difficult to write
> >my
> > own code to import a new field in Outlook from access ?
> >
> >
> > --
> > Best regards
> > Roberto

>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      7th Jan 2009
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" <(E-Mail Removed)> wrote in message
news:768B2744-5BBD-4B70-AD3C-(E-Mail Removed)...
> 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


 
Reply With Quote
 
Robby
Guest
Posts: n/a
 
      9th Jan 2009
Hello Ken,

Thanks for replying!

Okay, I have a table called xxx which is created in an Access database
called LS. This table contains a field that does not exist in the contact
items of MS Outlook. The field is called "TBK_Comment". I would like to
import all the fields from this table including the TBK_Comment field. I
really don't need more that this, except that in the future I my require to
bring over several fields instead of one field.

So basically now, if I import the table from Access into MS Outook, I am
able to import all the fields except the one that does not exist in Outlook.

So my question to you is, If I use the snippet of code you suppiled:

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

will this import the TBK_Comment field only? Suppose I would like to import
all the fields including the TBK_Comment field?

Also, does this snippet of code have to be inserted in a VBA macro?
at Tools>Macro>Macros ?

Thanks for your help!

--
Best regards
Roberto


"Ken Slovak - [MVP - Outlook]" wrote:

> 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" <(E-Mail Removed)> wrote in message
> news:768B2744-5BBD-4B70-AD3C-(E-Mail Removed)...
> > 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

>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      9th Jan 2009
Again, the import dialog won't import custom fields. So if you get your
table from Access as a recordset you first have to get each matching
existing contact for each table row before you can get to the custom field.

If the contacts to be imported don't exist you can use the Access table to
create the contacts one by one.

The code I showed gets one field from a recordset and sets that field in a
previously selected contact. The code would be in a VBA macro.

Let's say the contacts exist already and they are in the default Contacts
folder, and that you already have your Access recordset with fields for your
custom property and also for name or other identifying characteristics. This
would get your entire collection of Contacts:

Dim oFolder As Outlook.MAPIFolder
Dim colItems As Outlook.Items
Dim oNS As Outlook.NameSpace

Set oNS = Application.GetNameSpace("MAPI")
Set oFolder = oNS.GetDefaultFolder(olFolderContacts)
Set colItems = oFolder.Items

Then you'd need code to look at each contact in the Items and try to match
it with a row in your recordset. For iterating the Outlook Items:

Dim oContact As Outlook.ContactItem
For Each oContact In colItems

You'd then search the recordset for a matching contact row and once you have
that you'd be able to use the code I originally showed.

If you have any distribution lists in your folder that would fire an error
when the DL was hit and you attempted to assign it to a ContactItem object
(oContact). So you'd also need code to allow for that. A simple On Error
Resume Next and a test for oContact Is Nothing would work as a prerequisite
to getting into the loop code.

You might want to look at the database code samples at www.outlookcode.com
for various samples of doing this sort of thing with Outlook code.

--
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" <(E-Mail Removed)> wrote in message
news:340265C9-EB0D-4A91-B525-(E-Mail Removed)...
> Hello Ken,
>
> Thanks for replying!
>
> Okay, I have a table called xxx which is created in an Access database
> called LS. This table contains a field that does not exist in the contact
> items of MS Outlook. The field is called "TBK_Comment". I would like to
> import all the fields from this table including the TBK_Comment field. I
> really don't need more that this, except that in the future I my require
> to
> bring over several fields instead of one field.
>
> So basically now, if I import the table from Access into MS Outook, I am
> able to import all the fields except the one that does not exist in
> Outlook.
>
> So my question to you is, If I use the snippet of code you suppiled:
>
> ==========================================
> Dim oProp As Outlook.UserProperty
> Set oProp = oContact.UserProperties("TBK_Comment")
> If (oProp Is Nothing) Then
> Set oProp = oContact.UserProperties.Add("TBK_Comment", olText, True)
> End If
> oProp.Value = oRST.Fields("TBK_Comment")
> oContact.Save
> ============================================
>
> will this import the TBK_Comment field only? Suppose I would like to
> import
> all the fields including the TBK_Comment field?
>
> Also, does this snippet of code have to be inserted in a VBA macro?
> at Tools>Macro>Macros ?
>
> Thanks for your help!
>
> --
> Best regards
> Roberto


 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create new Field Chooser entry in Outlook 2007 Beach Lover Microsoft Outlook Discussion 4 14th Apr 2010 06:35 PM
Create a reply field in Outlook Thomas Microsoft Outlook Discussion 2 7th Jul 2008 10:48 PM
VBA code to create new Contacts field in Outlook =?Utf-8?B?UGF1bA==?= Microsoft Excel Programming 5 5th May 2007 10:26 PM
Outlook: how to create an import custom field map =?Utf-8?B?UGF1bFM=?= Microsoft Outlook Contacts 0 12th Aug 2006 03:20 AM
how i create combination field in outlook form? =?Utf-8?B?cmVnYXJkcywgQS5z?= Microsoft Outlook Form Programming 1 18th Apr 2006 01:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:08 AM.