Hi,
I am trying to attach a file from my local drive to one of the rich text fields using lotus Script. This can be done in Formula but the current situation demands it to be done in Lotus Script. Can anyone help me sorting this out?
Hi,
I am trying to attach a file from my local drive to one of the rich text fields using lotus Script. This can be done in Formula but the current situation demands it to be done in Lotus Script. Can anyone help me sorting this out?
Subject: Attachment
You will need to use
Set notesEmbeddedObject = notesRichTextItem.EmbedObject( type%, class$, source$, [ name$ ] )
type%
Constant. Indicates if you want to create an attachment, an embedded object, or an object link. May be any of the following:
EMBED_ATTACHMENT (1454)
EMBED_OBJECT (1453)
EMBED_OBJECTLINK (1452)
class$
String.
If you are using EMBED_OBJECT and want to create an empty embedded object from an application, use this parameter to specify the name of the application (for example, “1-2-3 Worksheet”) and specify an empty string (“”) for source$. Case-sensitive.
If you are using EMBED_OBJECTLINK or EMBED_ATTACHMENT, specify an empty string (“”).
source$
String.
If you are using EMBED_OBJECT and want to create an embedded object from a file, use this parameter to specify the name of the file, and specify an empty string (“”) for class$.
If you are using EMBED_ATTACHMENT or EMBED_OBJECTLINK, use this parameter to specify the name of the file to attach or link.
name$
String. Optional. Name by which you can reference the NotesEmbeddedObject later. This parameter is only used for OLE/2 objects and does not include attachments.
Subject: RE: Attachment
Hi Mike,Thanks for the prompt reply …but I have used the same thing …The piece of code is given below…I donno what went wrong in this…
files = workspace.OpenFileDialog(False, “Get Template”,“”, “c:”)
If Not(Isempty(files)) Then
Forall filename In files
path_of_file=Cstr(filename)
End Forall
End If
Set rtitem = New NotesRichTextItem( doc, "Attach_Setup_Form" )
Call rtitem.EmbedObject ( EMBED_ATTACHMENT , "", path_of_file)
Its actually an excel file which I want to attach to the rich text field which is not happenning. Can you help me in citing the error.
Thanks once again
Subject: RE: Attachment
What is the error? What is actually happening/not happening?
Subject: RE: Attachment
Hi Mike,
The attachment is not happening.
I am getting the directory dialog box to choose the file, I am able to select the file but after clicking the ‘open’ button the selected file is not getting attached…the field remains blank.
Subject: RE: Attachment
You will have to close and reopen the document to see the change. It is the nature of rich text fields that changes made via backend classes (including NotesRichTextItem) will not show automatically. See http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/fc13464ce2200d81852573e6000a3dfc?OpenDocument for one of many, many posts on this, as well as a link to a clear description of how to handle it.
Subject: RE: Attachment
You can try this out:
Create a form in which you can attach the files in a richtext field and in the form you can create field which will have the “name” field, for example you attach the file “zzz.xls” and the name can be “zzz”
Then create a view, say “files”, with this form as the selection formula and the 1st column with the “name” field of the form and it is sorted.
In the lotusecript you can try this code:
=============================
Dim MailView As NotesView
Dim MailDoc As NotesDocument
Dim Brtitem As NotesRichTextItem
Dim Path As String
Dim object As NotesEmbeddedObject, object1 As NotesEmbeddedObject
Path = Environ$(“TEMP”)
Set MailView = db.GetView(“files”)
Set MailDoc = MailView.GetDocumentByKey(“zzz”,True)
Set object = MailDoc.GetAttachment(“zzz.xls”)
Call object.ExtractFile(Path & "" & object.source)
Set object1 = Brtitem.EmbedObject(EMBED_ATTACHMENT,“”, Path & "" & object.source)
Kill Path & "" & object.source
=======================================
In this way you can have the “Brtitem” having the attachment in it.
Subject: RE: Attachment
Also see this: Front-end file attachments in LotusScript