What is the easiest way to send a message through Outlook using Ruby?

My job requires me to automate email generation for certain tests. I look around, but havent been able to find a reasonable solution that can be implemented quickly. It should be in Outlook, and not on some other mail server, since we have some weird authentication rules, and we need the option to save drafts instead of just sending a message.

Apparently win32ole can do this, but I cannot find enough simple examples.

+5
source share
2 answers

Assuming that the Outlook credentials are stored and you are set up for Outlook Autology, WIN32OLE does the trick pretty nicely:

require 'win32ole'
outlook = WIN32OLE.new('Outlook.Application')
message = outlook.CreateItem(0)
message.Subject = "Hey look a subject!"
message.Body = "Yes this is dog"
message.Recipients.Add 'dog@dog.com'
message.Recipients.Add 'cat@dog.com'
message.Attachments.Add('C:\Path\To\File.txt')
#Want to save as a draft?
message.Save
#Want to send instead?
message.Send

" Outlook Ruby: ", .

, , , Outlook.

+8

Outlook - ( outlook.com office365.com), Mikel Lindsaar Ruby. , POP3, IMAP4 SMTP.

Outlook Ruby, . , , .

0

All Articles