AboutPaski K. Paskaradevan Expertise I have 3 + years in Lotus Notes application development. I am a CLP R5 Application Development. I can answer any question pertaining to application development.
Experience R5 CLP. In addition, I have a bachelors degree in Engineering and a MBA.
Expert: Paski K. Paskaradevan Date: 6/18/2008 Subject: Attachments are not being sent in Lotusscript email script.
Question I have a button to send e-mail which contains richtext field on a form. When users put attachments in the fields, sometimes the attachments do not appear in the e-mail that was sent. Here is the code that we are using.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim workspace As New NotesUIWorkspace
Dim view As NotesView
Dim doc As NotesUIDocument
Dim docA As NotesDocument
Dim docB As NotesDocument
Dim rtitem As NotesRichTextItem
Dim item As NotesItem
Dim item2 As NotesItem
Dim item3 As NotesItem
Dim item4 As NotesItem
Dim item5 As NotesItem
Dim Subject As NotesItem
Dim success As Variant
Set db = session.CurrentDatabase
Set doc = workspace.CurrentDocument
Call doc.Save
Set docA = doc.Document
Call docA.Save( True, True )
' Call doc.Categorize("Tempdoc")
Set item = DocA.GetFirstItem("SendTo")
Set item2 = DocA.GetFirstItem("Subject")
Set item3 = DocA.GetFirstItem("CopyTo")
Set item4 = DocA.GetFirstItem("BlindCopyTo")
Set docB = New NotesDocument( db )
Success = docB.ComputeWithForm(False, False)
Set rtitem = New NotesRichTextItem( docB, "Body" )
Call docB.Save( True, True )
success = docA.RenderToRTItem( rtitem )
Call docB.Save( True, True )
If DocA.HasItem("GatewayName") Then
Set item5 = DocA.GetFirstItem("GatewayName")
Call docB.CopyItem(item5, "SendTo" )
Set Subject = New NotesItem(DocB,"Subject","ES_TAOForm-from-Notes")
Call DocB.Save(True,True)
Else
Call docB.ReplaceItemValue("SendTo",item )
Call docB.ReplaceItemValue("DisplayDatabase",item )
Call docB.ReplaceItemValue("Subject", item2)
If DocA.HasItem("CopyTo") Then
Call docB.ReplaceItemValue("CopyTo", item3 )
End If
If DocA.HasItem("BlindCopyTo") Then
Call docB.ReplaceItemValue("BlindCopyTo", item4 )
End If
End If
DocB.SignOnSend = True
DocB.SaveMessageOnSend = True
Call docb.Send(False)
Call doc.Close
Call DocB.Remove(True)
End Sub
Answer Hi,
All you need to do is after the attachment is added to the uidocument, save the uidocument and then send it. Looks like you alreday have the sendto, copyto fields etc. on the form and the uidocument will be sent to those specified in those fields.
Your code as written is doing unnecessary things (like transferring items from doca to docb etc.). Computewithform is totally unnecessary.
Write a very simple code and SAVE the document before sending it.