Instead of C:\temp need the document to attach to client email

Hope someone can help.I have an agent that detaches a document chosen by a user from a database, and then sends a draft message “test” to the users email draft folder and also the document to the user’s C:\temp folder.

I need the agent to open the user’s email for a new message composition and attach the document to it so the user can send to whomever they want for review.

I am unclear on how to:

1). open a new mail message

2). attach the chosen document.

The entire agent is below. Please offer assistance if you can.

Thank you.

Declarations:

Dim s_currentsession As NotesSession

Dim db_thisDatabase As Notesdatabase

Dim doc_RecordDoc As Notesdocument

Dim str_runtime As String

Dim int_doccount As Long

Dim int_currentdoc As Long

Dim dc As NotesDocumentCollection

initialize:

Sub Initialize

Call setup

' Start with the first row and start looping 

Call mainloop

End Sub

mainloop:

Sub mainloop

Set doc_RecordDoc = dc.GetFirstDocument()

While Not(doc_RecordDoc Is Nothing)

	Messagebox 

doc_RecordDoc.Titleopp(0), MB_OK, “Selecting”

	Call detach

	Call draft_msg

	Call 

s_currentsession.UpdateProcessedDoc( doc_RecordDoc )

	Set doc_RecordDoc = 

dc.GetNextDocument(doc_RecordDoc)

Wend

End Sub

setup:

Sub setup

' Create new objects where necessary and 

point to the correct view.

Set s_currentsession = New NotesSession

’ Connect to the database, create a query, and

execute it.

Set db_thisDatabase = 

s_currentsession.CurrentDatabase

Set dc = 

db_thisDatabase.UnprocessedDocuments

End Sub

detach:

Sub detach

Dim rtitem As Variant

Dim object As NotesEmbeddedObject

Dim handle As Variant

'…set value of doc…

Set rtitem = doc_RecordDoc.GetFirstItem( 

“deliverable” )

If ( rtitem.Type = RICHTEXT ) Then

	Forall o In rtitem.EmbeddedObjects

		If ( o.Type = 

EMBED_ATTACHMENT ) Then

			Messagebox o.Source, 

MB_OK, “Detaching”

			Call o.ExtractFile( 

"c:\temp" & o.Source )

		End If

	End Forall

End If

End Sub

draft message:

Sub draft_msg

Dim ws As New notesuiworkspace

Dim session As New notessession

Dim uidoc As notesuidocument

Dim doc As notesdocument

Dim db2 As notesdatabase

Dim view2 As notesview

Dim doc2 As NotesDocument

Dim subj As Variant

Dim note As NotesRichTextItem

Dim item As NotesItem

Dim username As New 

NotesName(session.UserName)

strUser = username.canonical



server$ = session.GetEnvironmentString 

(“MailServer”, True) 'Get user’s home/mail server

mailfile$ = session.GetEnvironmentString 

(“MailFile”, True) 'Get user’s mail file name

Set db2 = session.getdatabase 

(server$,mailfile$)

’ Set view2 = db2.getview (“Drafts”)

Set doc2 = db2.createdocument

Call doc2.replaceItemValue("Form","Memo")

Call doc2.replaceItemValue("Subject","test")



Call doc2.save(True,False)

Call s_currentsession.UpdateProcessedDoc( 

doc_RecordDoc )

Messagebox "A draft message has been created 

with your selections."

End Sub

Subject: RE: instead of C:\temp need the document to attach to client email

Create the NotesDocument object first in the back-end.Create a NotesRichTextItem in it.

Use EmbedObject method to add the attachment.

EditDocument method to open it.

If the user has an automatic signature it will appear above the atttachment. Nothing much to be done about this.