Forum: Ruby Ruby + Lotus Domino oh my!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2a0f7bd2c54fbc44329d69555b96f1c5?d=identicon&s=25 kevin.jackson (Guest)
on 2005-12-08 06:10
(Received via mailing list)
Hi,

Does anyone have any experience interfacing ruby to Notes/Domino?  I
only need to do a data extract, and I absolutely do not want to have to
code up C/Java just to suck the data out of a Notes database.

I could (in theory) hack up a Notes agent to export the database it was
in, but I doubt I'll be allowed to mess with it in that much detail,
simple ODBC hookup will be about as good as it gets I think

Kev
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 wilsonb (Guest)
on 2005-12-08 22:35
(Received via mailing list)
If you can run Ruby on the same box as Domino, you can do this.  This
particular kind of access doesn't work across systems.  (Untested
code, use as directed, etc, etc.)
require 'win32ole'
SERVER_NAME = 'example/M/ORG'
USER_NAME = 'godmode'
NOTES_PASSWORD = 'supersecret'
DB_NAME = 'example.nsf'

s = WIN32OLE.new 'Lotus.NotesSession'
s.InitializeUsingNotesUserName(USER_NAME, NOTES_PASSWORD)
db = s.GetDatabase(SERVER_NAME, DB_NAME)
view = db.GetView "All Documents"
entry = view.GetFirstDocument # I hate the Notes COM interface.
while entry
  doc = entry.Document
  puts doc.GetFirstItem("Subject").Values
  puts doc.GetFirstItem("Categories").Values
  entry = view.GetNextDocument(entry) # Yes, this is weird.
end

Once you've gotten that working, you can read up on the various evil
COM methods here:
http://rubyurl.com/Rry

Personally, I find them easier to view them inside Visual Studio's
"object browser".

--Wilson.
04d072ab8843cfd3d1714faf3a2a0fb2?d=identicon&s=25 mathew (Guest)
on 2005-12-16 23:24
(Received via mailing list)
Kev Jackson wrote:
> Does anyone have any experience interfacing ruby to Notes/Domino?  I
> only need to do a data extract, and I absolutely do not want to have to
> code up C/Java just to suck the data out of a Notes database.

If there's a Domino server involved (i.e. it's not just a database on a
Notes client), use Domino's standard XML facilities.

If there's no Domino server involved, write a quick LotusScript agent to
export to XML... :-)


mathew
E9488ef674513283e2822ba162559131?d=identicon&s=25 Sam Dela Cruz (Guest)
on 2005-12-16 23:33
(Received via mailing list)
In my company, we use Lotus Notes, here's how I extract messages from
one
folder from my mailfile.  You can easily modify this to get data from
any
notes database:

require 'win32ole'

application = WIN32OLE.new('Notes.NotesSession')
database = application.GetDatabase('Server','DatabaseFile')
response = database.GetView('Folder')
count = response.TopLevelEntryCount
index = count

filename = "results.csv"
file = File.new(filename,'w+')

count.times do
    document = response.GetNthDocument(index)
    index -= 1
        text = document.GetFirstItem('Body').Text

        machineName = ""
        userAccount = ""
        mappings = []

        text.split("\r\n").each do |line|
            line.chomp
                (key,value) = line.split("=")
                if key == "MachineName"
                    machineName = value
                elsif key == "Mapping"
                    mappings.push(value)
                        re = /^.*\\(\w{3}\d{5})$/
                        re.match(value)
                        userAccount = $1
        end
        end
        file.puts userAccount + "," + machineName + "," +
mappings.join(",")
end
file.close

Regards,
Sam Dela Cruz









mathew <meta@pobox.com>
12/16/2005 02:22 PM
Please respond to
ruby-talk@ruby-lang.org


To
ruby-talk@ruby-lang.org (ruby-talk ML)
cc

Subject
Re: Ruby + Lotus Domino oh my!
Classification







Kev Jackson wrote:
> Does anyone have any experience interfacing ruby to Notes/Domino?  I
> only need to do a data extract, and I absolutely do not want to have to
> code up C/Java just to suck the data out of a Notes database.

If there's a Domino server involved (i.e. it's not just a database on a
Notes client), use Domino's standard XML facilities.

If there's no Domino server involved, write a quick LotusScript agent to
export to XML... :-)


mathew
E9488ef674513283e2822ba162559131?d=identicon&s=25 Sam Dela Cruz (Guest)
on 2005-12-16 23:39
(Received via mailing list)
Sorry, the tab spaces were kind of messed-up, here's the same code with
tabs adjusted...

require 'win32ole'

application = WIN32OLE.new('Notes.NotesSession')
database = application.GetDatabase('Server','DatabaseFile')
response = database.GetView('Folder')
count = response.TopLevelEntryCount
index = count

filename = "results.csv"
file = File.new(filename,'w+')

count.times do
        document = response.GetNthDocument(index)
        index -= 1
        text = document.GetFirstItem('Body').Text
        machineName = ""
        userAccount = ""
        mappings = []

        text.split("\r\n").each do |line|
                line.chomp
                (key,value) = line.split("=")

                if key == "MachineName"
                        machineName = value
                elsif key == "Mapping"
                        mappings.push(value)
                        re = /^.*\\(\w{3}\d{5})$/
                        re.match(value)
                        userAccount = $1
                end
        end
        file.puts userAccount + "," + machineName + "," +
mappings.join(",")

end
file.close

Regards,
Sam










Sam Dela Cruz <sam.dela.cruz+FromInternet@philips.com>
12/16/2005 02:31 PM
Please respond to
ruby-talk@ruby-lang.org


To
ruby-talk@ruby-lang.org (ruby-talk ML)
cc

Subject
Re: Ruby + Lotus Domino oh my!
Classification







In my company, we use Lotus Notes, here's how I extract messages from
one
folder from my mailfile.  You can easily modify this to get data from
any
notes database:

require 'win32ole'

application = WIN32OLE.new('Notes.NotesSession')
database = application.GetDatabase('Server','DatabaseFile')
response = database.GetView('Folder')
count = response.TopLevelEntryCount
index = count

filename = "results.csv"
file = File.new(filename,'w+')

count.times do
    document = response.GetNthDocument(index)
    index -= 1
        text = document.GetFirstItem('Body').Text

        machineName = ""
        userAccount = ""
        mappings = []

        text.split("\r\n").each do |line|
            line.chomp
                (key,value) = line.split("=")
                if key == "MachineName"
                    machineName = value
                elsif key == "Mapping"
                    mappings.push(value)
                        re = /^.*\\(\w{3}\d{5})$/
                        re.match(value)
                        userAccount = $1
        end
        end
        file.puts userAccount + "," + machineName + "," +
mappings.join(",")
end
file.close

Regards,
Sam Dela Cruz









mathew <meta@pobox.com>
12/16/2005 02:22 PM
Please respond to
ruby-talk@ruby-lang.org


To
ruby-talk@ruby-lang.org (ruby-talk ML)
cc

Subject
Re: Ruby + Lotus Domino oh my!
Classification







Kev Jackson wrote:
> Does anyone have any experience interfacing ruby to Notes/Domino?  I
> only need to do a data extract, and I absolutely do not want to have to
> code up C/Java just to suck the data out of a Notes database.

If there's a Domino server involved (i.e. it's not just a database on a
Notes client), use Domino's standard XML facilities.

If there's no Domino server involved, write a quick LotusScript agent to
export to XML... :-)


mathew
This topic is locked and can not be replied to.