Link to home
Start Free TrialLog in
Avatar of ananddotiyer
ananddotiyerFlag for India

asked on

OLE in C#

How can I control OLE objects using C# .NET, in the same way as Perl uses "WIn32::OLE" for Lotus Notes.
Avatar of abel
abel
Flag of Netherlands image

A step by step tutorial on how to send a mail through lotus notes using OLE can be found here: http://www.notes411.com/dominosource/tips.nsf/0/2114E009A8C8D089802571B6003CD7C4!opendocument
FYI: The article linked above describes using COM, not OLE.  The way you use them is similar, but the objects and methods are different.

If you want to automate Notes using OLE, make sure you add the "Lotus Notes Automation Classes" library to your project.  The "Lotus Domino Objects" library is the COM one.

Let me know if you need help understanding the differences between the libraries.  I also have working examples in C# using both libraries.
Yes, Bill is correct in stressing the differences between OLE and COM. COM is the successor to OLE (amongst other things,  it served a larger purpose) and there are indeed differences.
Avatar of ananddotiyer

ASKER

yes, I would like a walk-through on how to use the "Lotus Notes Automation Classes" in C#.  that would be great.  

thank you for the replies!
No problem.

First, you should understand the differences between the libraries so that you can make the right choice for your project.  Here are the main differences:

COM
  • Early-bound objects use the "Lotus Domino Objects" library.
  • Late-bound objects are named using the Lotus prefix (ie: Lotus.NotesSession).
  • The Notes client must be installed, but does not need to be running.
  • You must call the NotesSession.Initialize method, passing the password of the most recent user.  Passing an empty string will cause the library to prompt the user to login (Unless the client is already running, in which case the current login is used and the Initialize method simply returns).
  • Frontend objects cannot be used!!!
OLE
  • Early-bound objects use the "Lotus Notes Automation Classes" library.
  • Late-bound objects are named using the Notes prefix (ie: Notes.NotesSession).
  • The Notes client must be installed and running.  If the client is not running, the OLE server will automatically start it and prompt the user to log in.
  • There is no NotesSession.Initialize method.  Authentication is obtained through the running client.
  • Frontend objects are supported!
So, in a nutshell, use COM if you only need to perform background operations or if you need to login to Domino using another user's id.  Use OLE only if you need access to frontend objects (like the current form open in the Notes client).  Best practice is to use COM unless you must use OLE.

Next, decide which library to use, and let me know basically what you are trying to accomplish so I can provide some examples.
I've rarely seen such clear explanation of two otherwise quite related technologies. Nice comment, Bill ;-)
Thanks!  It took many hours of research and trial an error to sort these libraries out.
Can I get an example of accessing a mail using OLE library in C#?
ASKER CERTIFIED SOLUTION
Avatar of Bill-Hanson
Bill-Hanson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
THanks Bill for the amazing explanation and the example code.  I shall try this out and let you know, but meanwhile I must tell you, I really appreciate all the effort you spent on getting this to me...

thanks once again!
Anand
Thanks Bill!
Thank you very much Bill for this very helpful article about C# and OLE.
Iam using in my application C# and OLE for creating a new Notes memo. It (Bill's code) works fine apart from adding attachments to the memo.
I would be grateful if someone could tell how OLE automation classes can be used to add attachments to a memo?

thanks in advance
@nobana81,

If you'd like to ask a question, then post a new question.  No fair piggy backing off of someone else's question.

Also, if you search this site, you'll find several examples by myself and others.
Hello Bill,

I have already asked this question in a separate thread but I still have no answer to it (only unusual comments or links refering to com early binding and not ole late binding).

You can find my question here: https://www.experts-exchange.com/questions/26421684/Adding-attachment-to-lotus-notes-memo-using-C-and-OLE-Automation-Classes.html

It would be very nice when you could look at that question and give me some hints or sample code to attach files to a memo using late binding.

Many thanks in advance
OK, I'll take a look.

Sorry for commenting a closed question,

but I have a related question and because I find the answers of Bill very very helpfull, I would be very gratefull if Bill could take a look at my question here:

https://www.experts-exchange.com/questions/26675548/Getting-inline-images-from-lotus-notes-email-using-C-and-com-early-binding.html

Many thanks in advance.