Hello;I am very close but stuck and would greatly appreciate some help.
This agent below detaches a document from the databse, stores it in C:\temp and also sends a test message to draft folder in user email.
I am stuck at actually opening the user email and embedding the document into it.
Can someone please offer a way to do this with existing code. I have scoured the help files and find snippets but cannot put together to get this working.
Thank you in advance for any help.
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