Dear all,I have a form with rich text lite field which I can attach file in this field and after that i want to transfer the content of the rich text field to Mailbox Memo form so that I can send the mail with attachment to others.
Below is the script that i wrote, but it always give me error “object variable not set” on the line
"If ( rtitemA.Type = RICHTEXT And doc.HasEmbedded ) Then "
Dim ws As New NotesUIWorkspace
Dim ss As New NotesSession
Dim db As NotesDatabase, mdb As NotesDatabase
Dim uidoc As NotesUIDocument, mdoc As NotesUiDocument
Dim doc As NotesDocument, adoc As NotesDocument, tddoc As NotesDocument
Dim avw As NotesView
Dim rtitemA As Variant
Dim rtitemB As Variant
Dim rtitemmail As Variant, rtitem As Variant
Set db = ss.CurrentDatabase
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
subject = doc.Project_Doc_Subject(0)
’ *** Check user’s mail filename *****
svr$ = db.server
Set mdb = ss.GetDatabase(svr$, “names.nsf”, True)
Set nam = ss.CreateName( ss.UserName)
abbusernm = nam.Abbreviated
Set avw = mdb.GetView(“($VIMPeople)”)
Set adoc = avw.GetDocumentByKey(abbusernm, True)
If Not adoc Is Nothing Then
mailboxname = adoc.MailFile(0)
End If
’ ***** Compose New Memo ******
Set mdb = ss.GetDatabase( svr$, mailboxname, True )
If Not mdb.IsOpen Then Messagebox “Fail to update task, To Do List is not linked !”
Set mdoc = ws.ComposeDocument( svr$, mailboxname, “Memo”)
Call mdoc.FieldSetText(“Subject”, subject)
Forall rec In doc.SendTo
Call mdoc.FieldAppendText("EnterSendTo", rec & ", ")
End Forall
Set tddoc = mdoc.Document
Set rtitemB=New NotesRichTextItem (tddoc, “Body”)
Set rtitemA = doc.getfirstitem(“Project_Attachment”)
If ( rtitemA.Type = RICHTEXT And doc.HasEmbedded ) Then
Forall o In rtitemA.EmbeddedObjects
Select Case o.Type
Case EMBED_OBJECT
fname = o.Name
Call o.ExtractFile( "C:\" & fname )
Set object = rtitemB.EmbedObject( EMBED_OBJECT, "", "C:\" & fname )
Kill "C:\" & fname
End Select
End Forall
End If
Please advice. Thank you.