win32ole ---> Outlook

As a continuation to an earlier post on win32ole-excel interaction, this section will talk about using win32ole to talk to microsoft outlook:


require 'win32ole'
    outlook = WIN32OLE.new('Outlook.Application')
    message = outlook.CreateItem(0)
    message.Subject = "#{subj}"
    message.Body = "#{text}"
    message.Recipients.Add 'abc@abc.com'
    message.Recipients.Add 'xyz@xyz.com'

    if attachment_file!=""
      message.Attachments.Add("#{attachment_file}")
    end

    #Want to save as a draft?
       message.Save

    #Want to send instead?
       message.Send


Comments

Popular Posts