[wtr-general] Re: Outlook recommendations

2008-10-20 Thread al3kc

Does anyone know how to click link from message?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Watir General group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---



[wtr-general] Re: Outlook recommendations

2008-10-15 Thread Peter

I started down the path of automating Outlook via com but ran into
issues with security pop ups that discourage scripting. I was able to
script past the pop ups (sometimes) but the behavior of the pop ups
were not consistent. I've given up on this since then. Here's the code
I had written in case someone is interested in breaking the security
features.

#http://snippets.dzone.com/posts/show/4232

require 'breakpoint'
require 'win32ole'

class Outlook
DELETE_ITEMS = 3
OUTBOX   = 4
SENT_MAIL= 5
INBOX= 6
CALENDAR = 9
CONTACTS = 10
JOURNAL  = 11

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

@dir = File.expand_path(__FILE__)
@dir = @dir[0 .. @dir.rindex('/')-1]
end

def send(to, subject, body, attachment_path=nil)
system(start ruby.exe [EMAIL PROTECTED]/email_security.rb send)

message = @outlook.CreateItem(0)
message.Subject = subject
message.Body = body
message.To = to
message.Attachments.Add(attachment_path, 1) if attachment_path

begin
  message.Send()
rescue Exception = e
  puts Send threw an exception
end
end

def get_unread(folder='Inbox')
array = []
get_folder(folder).Items.each do |message|
array  message
end
return array
end

def get_unread_count(folder='Inbox')
return get_folder.UnreadItemCount
end

def get_folder(folder='Inbox')
ofolder = @mapi.GetDefaultFolder(INBOX)
ofolder = @mapi.GetDefaultFolder(INBOX).Folders.Item(folder)
if folder!='Inbox'
#folder = @mapi.Folders.Item('Archive
Folders').Folders.Item('Inbox')
return ofolder
end

# gets a message from a folder
# - how to get the message
[:from, :subject, :Body, :Attachments]
# - what to use for searching (examples, Peter Chau, RE: Test
email)
def get_message(how, what, folder='Inbox')
system(start ruby.exe [EMAIL PROTECTED]/email_security.rb read)

get_folder(folder).Items.each do |message|
begin
case how# [receivedByName, senderName, .to]
when :body
(return message if message.body =~ what) if
what.is_a?(Regexp)
(return message if message.body == what) if
what.is_a?(String)
when :subject
(return message if message.subject =~ what) if
what.is_a?(Regexp)
(return message if message.subject == what) if
what.is_a?(String)
when :senderName
(return message if message.senderName =~ what)
if what.is_a?(Regexp)
(return message if message.senderName == what)
if what.is_a?(String)
end
rescue Exception = e
end
end

puts did not find email with #{how} = '#{what}'
return nil
end
end

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Watir General group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---