Over a million developers have joined DZone.

Automating Outlook With Ruby: Contacts

DZone's Guide to

Automating Outlook With Ruby: Contacts

· ·
Free Resource
From the Ruby on Windows blog...

require 'win32ole'

outlook = WIN32OLE.new('Outlook.Application')
mapi = outlook.GetNameSpace('MAPI')

#   Create a new Contact
contact = outlook.CreateItem(2)
    contact.FullName = 'Stan Musial'
    contact.BusinessTelephoneNumber = '(314)555-1234'
    contact.Email1Address = 'stan_the_man@stlcardinals.com'

#   Iterate over Contact Items and extract data
contacts = mapi.GetDefaultFolder(10).Items
contacts.each do |contact|
    puts contact.FullName
    puts contact.Email1Address
    puts contact.BusinessTelephoneNumber

Further details can be found here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}