Attachment into memo UI doc?

This is my first foray into Lotus Script so excuse me if I’m a bit clueless!

I’m trying to generate a memo form in the current users email database from another notes database - and copy an attachment from the current open form in other database into the body of the new memo form. My code currently looks like this - its triggered by an action button from a form:

Sub EmailQuote()

'Declare backend objects

Dim doc As NotesDocument

Dim db As NotesDatabase

Dim item As NotesItem

Dim session As New NotesSession

Dim UserMailServer As String

Dim UserMailFile As String

Set db = session.CurrentDatabase

'Declare front end objects

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim sEmailSubject As String

Dim sSendTo As String

Dim memo As NotesUIDocument

Set uidoc = workspace.CurrentDocument

'get the attachments from the document

Set doc = uidoc.Document

Set item = doc.GetFirstItem( "GeneratedQuotes" )

'create email with attachment

sEmailSubject = "TMG Quote"

sSendTo = "Jason Hornbuckle"

UserMailServer = session.GetEnvironmentString("MailServer",True)

Set Mailserver = New NotesName(UserMailServer)

UserMailFile = session.GetEnvironmentString("MailFile",True)

Set memo = workspace.ComposeDocument(MailServer.Abbreviated,UserMailFile,"Memo")

Call memo.FieldSetText("EnterSendTo",sSendTo)

Call memo.FieldSetText("Subject",sEmailSubject)

Call item.CopyItemToDocument(memo, "Body") 'This is the part that isnt working!!

End Sub

It all works fine except that I cant work out how to get the attachment into the memo body field? The “CopyItem” method appears to only work for a back-end document? As I had it working to generate an email with the attachment and automatically send to a recipient - but I need the users to be able to manually edit the body field(ie enter a message) before the email is sent. Is there a way to do this?

Subject: Attachment into memo UI doc?

Jason,

as you state, creating the memo as a backend document works fine.

Perhaps I missed something (because I feel that this solution is too easy), but how about just opening that document to the workspace after creating the backend document?

The notesuiworkspace.editdocument() method will help you to do this.

See the designer help, that’s quite good on this!

Note: in your code, you did not save your memo document! In order to use notesuiworkspace.editdocument() you need to save it before.

Subject: RE: Attachment into memo UI doc?

Thanks Stephan,

No your not missing anything - as I mentioned this is my first go at learning Lotus Script so I’m still getting a handle on the language and how the back-end/front-end docs interact, Previously I’d only used @functions and @Commands but was finding myself too limited.

I eventually got it working with your suggestions - my email code now looks like this:

Dim mailDb As New NotesDatabase(“” , “”)

Call mailDb.OpenMail

Set newmemo = mailDb.CreateDocument

newmemo.Form = "Memo"

newmemo.Subject = "TMG Quote"

newMemo.From = "Jason Hornbuckle"

newMemo.SendTo = "Jason Hornbuckle"

Call newMemo.CopyItem(item, "Body")

Call newmemo.Save(True,True)

Call workspace.EditDocument(True, newmemo)

This appears to work fine. Now I can go and substitute the constants for setting the memo fields with variables passed in from the original document and it should work how I want it!

Cheers

Subject: RE: Attachment into memo UI doc?

Jason,

great! Congratulations!

Lotusscript can be some fun if you’re getting used to the syntax, methods and properties a little bit …

Have fun,

Stephan