Adding a ContactItem to a Contact Folder

Ok, I’m new to Ruby and new to Office Objects – double whammy. I’m simply
trying to add a new Contact item to the default contact folder. This is my
baby step. In the long run I have a database of over 100,000 Contacts I
need to dump into Outlook. I thought this would be a good application for
Ruby. I’m having trouble though.

require 'win32ole’
outlook = WIN32OLE.new(“outlook.application”)
oNameSpace = outlook.getNameSpace(‘MAPI’);
contactFolder = oNameSpace.GetDefaultFolder(10)

contact = outlook.CreateItem(2)
contact.lastName = "Bar"
contact.firstName = "Foo"
contact.homeTelephoneNumber = “703-333-3456”

I thought I should be able to do
contactFolder.Add(contact) # OR
items = conact.Items
items.Add(contact)

I keep getting the missing_method error on the Add function. I have tried a
lot of other things, which did not work. So, this is where I am now. If I
remove the line with items.Add or contactFolder.Add – i get no errors. Any
help would be appreciated. Also, I have found the Office Object Models on
MSDN – this is a huge help, but if there are good examples of Outlook
automation, that would be great. (well, great if they are in Ruby, good if
they are in VB, which is likely. :slight_smile:

Adding a ContactItem to a Contact Folder.Hello,

In the long run I have a database of over 100,000 Contacts I need to dump
into Outlook. I thought this would be a good application for Ruby.
I’m having trouble though.

This is the only way I was able to make it work:

contact = contactFolder.Items.Add( 2 )
contact.lastName = “Bar”
contact.firstName = “Foo”
contact.homeTelephoneNumber = “703-333-3456”
contact.Save

Regard,
M.

those method names (i.e. Add, Save) really have capital first letters? that
scares me.

···

On Sunday 26 January 2003 03:20 am, Milan Maksimovic wrote:

Adding a ContactItem to a Contact Folder.Hello,

In the long run I have a database of over 100,000 Contacts I need to
dump into Outlook. I thought this would be a good application for Ruby.
I’m having trouble though.

This is the only way I was able to make it work:

contact = contactFolder.Items.Add( 2 )
contact.lastName = “Bar”
contact.firstName = “Foo”
contact.homeTelephoneNumber = “703-333-3456”
contact.Save

Regard,
M.


tom sawyer, aka transami
transami@transami.net

Those are the VB names, but VB isn’t case sensitive, so add, save should
also work.

···

Tom Sawyer (transami@transami.net) wrote:

On Sunday 26 January 2003 03:20 am, Milan Maksimovic wrote:

Adding a ContactItem to a Contact Folder.Hello,

In the long run I have a database of over 100,000 Contacts I need to
dump into Outlook. I thought this would be a good application for Ruby.
I’m having trouble though.

This is the only way I was able to make it work:

contact = contactFolder.Items.Add( 2 )
contact.lastName = “Bar”
contact.firstName = “Foo”
contact.homeTelephoneNumber = “703-333-3456”
contact.Save

Regard,
M.

those method names (i.e. Add, Save) really have capital first letters? that
scares me.


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04