This function was written to create a Lotus email, populate it, save it to the Drafts section, and then open it for the user to edit. However, it has 2 problems:
- It doesn't always open the right draft email for editing.
- It sometimes produces a "Notes Error - Specified command is not available from the workspace." error message. (The email is still saved, so it's no big loss).
Both problems occur at irregular intervals. If there's a pattern, I haven't seen it yet. Can I make these problems go away? Any other tips on reducing errors here?
(Note: I'm leaving out the error handler)
Dim NtSession As New NotesSession
Dim NtDB As New NotesDatabase
Dim NtWkSp As Object
Dim NtDoc As New NotesDocument
Dim NtObj As New NotesEmbeddedObject
Dim NtBodyRT As New NotesRichTextItem
NtSession.Initialize
'==========================================================================
'Open the mail server
Set NtDB = NtSession.GetDatabase( _
NtSession.GetEnvironmentString("MailServer", True), _
NtSession.GetEnvironmentString("MailFile", True), _
True)
'==========================================================================
'Fill in basic email fields
Set NtDoc = NtDB.CreateDocument
NtDoc.AppendItemValue "Form", "Memo"
Set NtBodyRT = NtDoc.CreateRichTextItem("Body")
AddFields
'=========================================================================
' Save it to the drafts folder
DoEvents
NtDoc.SaveMessageOnSend = True
NtDoc.SignOnSend = True
NtDoc.Save False, False, True
Set NtWkSp = CreateObject("Notes.NotesUIWorkspace")
DoEvents
NtWkSp.OpenDatabase _
NtSession.GetEnvironmentString("MailServer", True), _
NtSession.GetEnvironmentString("MailFile", True), _
"($Drafts)"
DoEvents
NtWkSp.VIEWREFRESH
NtWkSp.EDITDOCUMENT
Set NtWkSp = Nothing
Set NtSession = Nothing