C#
--
Questions
--
Followers
Top Experts
I have found a great code snippet provided by Bill
(https://www.experts-exchange.com/questions/24463136/OLE-in-C.html#discussion)
that allows me to create a new memo using C# and OLE. Â Now I want to add attachments to that memo and Iam not able to do that. I would be very grateful if someone could share some C# code to add attachments to a memo.
I have tried the following but without success:
NotesUIDocument.InvokeMemb
Many thanks in advance.
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
https://www.experts-exchange.com/questions/20461546/Editing-Memos-with-Attachments-from-C.html
http://www.notes411.com/dominosource/forum.nsf/0/D677B3FF8EC833928025726000514A64!opendocument
http://www.redbooks.ibm.com/redpapers/pdfs/redp3868.pdf
http://stackoverflow.com/questions/1446633/extract-export-attachements-from-lotus-notes-email-using-c
I have already visited all the links you have listed above, but unfortunately the solutions proposed their are based on the COM-Interface.
Since I want to interact with the frontend objects (i.e. create a memo and show it to the user for further edit), I need the OLE automation classes (i.e. late binding).
I would really appreciate some further hints for adding attachments to a memo using C# and late binding






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
OLE automation uses late binding. You cannot create new Domino objects as you would in LotusScript. You must create (for example, with CreateObject) a Notes.NotesUIWorkspace or Notes.NotesSession object and work down through the hierarchies using the available methods. For example, if you want to open a Domino back-end database, create a Notes.NotesSession OLE automation object, and then use the GetDatabase method of NotesSession to set a reference variable.
In Visual Basic, declare the reference variables for all Domino objects as type Object. When you finish using a Domino object, set the reference variable to Nothing to free the memory it uses.
Use dot notation, just as in LotusScript, to access the properties and methods of an object.
Constants must be specified by actual numeric value rather than name. In LotusScript, you can get the value by displaying it in LotusScript
Bill's working solution:
Type NotesSession = Type.GetTypeFromProgID("No
Type NotesUIWorkspace = Type.GetTypeFromProgID("No
Object sess = Activator.CreateInstance(N
Object ws = Activator.CreateInstance(N
String mailServer = (String)NotesSession.Invok
String mailFile = (String)NotesSession.Invok
NotesUIWorkspace.InvokeMem
Object uidb = NotesUIWorkspace.InvokeMem
Object db = NotesUIWorkspace.InvokeMem
Type NotesDatabase = db.GetType();
// compose a new memo
Object uidoc = NotesUIWorkspace.InvokeMem
Type NotesUIDocument = uidoc.GetType();
NotesUIDocument.InvokeMemb
 NotesUIDocument.InvokeMemb
NotesUIDocument.InvokeMemb
NotesUIDocument.InvokeMemb
//add attachment to memo?????????....................HowTo.
http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/fd9d44793730806785256e360050f2d4?OpenDocument
http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/eec5ab3fe7e76515852571250005b618?OpenDocument
http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/2e6013654e5e63258525756f005201f8?OpenDocument

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
http://www.access-programmers.co.uk/forums/showthread.php?t=39253






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
I guess the point of them was:
declare your objects as "objects" (cause their type is not yet defind upon binding, therefore latebinding) and uste Notes.Classname instead of Lotus.Classname, as Lotus refers to COM and Notes to OLE
invoke the method AppendRTFile("Path")
http://www-12.lotus.com/ldd/doc/lotusscript/lotusscript.nsf/1efb1287fc7c27388525642e0074f2b6/cab1209e5dc2215e8525642e007537ab?OpenDocument
now attach the object of NotesRichTextItem in your object array.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=/com.ibm.designer.domino.main.doc/H_EXAMPLES_NOTESRICHTEXTITEM_CLASS.html
@ iPinky: your links discuss how to create plaintext memos and how to edit existing notes documents using there universalId but unfortunately NOT how to add attachments to a composed document using late binding. If you I have already done this, could you please post the two lines of code (additional to the code I have posted above, which creates the memo) to attach a file to that memo? I would be very grateful!
@puru198: your last link does not use late binding and is written in vb. the next to the last link sounds great, I have tried this approach with the following code but without success. I would be very nice if you could please correct the code or better send me only the code (additional to the code I have posted above, which creates the memo) to attach a file to the memo using late binding?
Type rti = Type.GetTypeFromProgID("No
Other hints or better sample code to attach files to memos using C# and late binding would be highly appreciated.
Thanks in advance.
you can get the classes and there methods definition here:
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=/com.ibm.designer.domino.main.doc/H_EXAMPLES_NOTESRICHTEXTITEM_CLASS.html
the above link is bible for the lotus notes.
i don't think you will get more information on OLE automation on net. everywhere you will find the similar type of code (early binding because it is easy to reference the objects and use in the project).
if you have bought this then IBM can help you out on OLE automation.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
thanks for the helpful hints. I have already tried the Workaround#1. It works fine for Notes8 but unfortunately not for Notes7 (an exception is thrown) and the most of my users have Notes7 running:-(
Iam using the following line of code to paste a file from the clipboard to the created memo:
NotesUIDocument.InvokeMemb
 Iam I missing something?
There's two things that you need to be aware of in order to use InvokeMember effectively.
- You need to understand what each parameter in InvokeMember is used for.
 - You need to understand the signature of the method that you are trying to invoke.
 
Type.InvokeMember looks like this:
public object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args);
- name - the name of the method that you want to invoke.
 - invokeAttr - for most Lotus objects, this will be either BindingFlags.GetProperty or BindingFlags.InvokeMethod depending on what you need to do.
 - binder - null.
 - target - The object that contain the property or method that you will invoke.
 - args - an array or arguments to pass to the method.
 
Call notesUIDocument.Paste
As you can see, paste does not take any arguments, so the args parameter in InvokeMember needs to be null.
Also, the documentation says "Pastes the contents of the Clipboard at the current cursor position on a document.". Â The important thing to note here is that it pastes the contents 'at the current cursor position'. Â Since the cursor is placed the Subject field on compose, you need to change the focus to the Body field before pasting. You can use NotesUIDocument.GotoField for this...
Call notesUIDocument.GotoField(
Since GotoField takes 1 parameter, our args param needs to be new Object[] { "Body" }.
NotesUIDocument.InvokeMember("GotoField", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "Body" });
NotesUIDocument.InvokeMember("Paste", BindingFlags.InvokeMethod, null, uidoc, null);
Copying Files from Clipboard using "GotoField" and "Paste" work only with Notes8 but unfortunately not with Notes7.
Using Notes7 Iam getting the exception: {System.Runtime.InteropSer
I think this is because copy-paste (using ctrl+c and ctrl+v) from outside Notes doesn' t work using Notes7; but It does using Notes8.
My idea was to use "GotoField" -> "Attachment" and then use "Paste" like in the following Code. But I think there is no field called "Attachment":
NotesUIDocument.InvokeMemb
Greetz                                                                   Â

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Regarding "GotoField", Notes does not have a field named "Attachment". Â All file attachments belong in the "Body" field in Lotus land.
C#
--
Questions
--
Followers
Top Experts
C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).