Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating New Memo from .NET

Status
Not open for further replies.

helpmonny

Technical User
Feb 25, 2002
21
0
0
GB
I'm creating a new Notes mail message from .NET using the code below. It seems to work fine and creates a new memo and leaves it open in edit mode but if you are not a Lotus Notes Administrator, it also throws an exception at the end, even though it's worked fine? Any ideas why?

Public Function CreateMail(ByVal Recipient As Collection) As Boolean
Dim Addresses As New StringBuilder
Dim i As Integer
Dim NotesSession As Object
Dim NotesDb As Object
Dim NotesDoc As Object
Dim NotesWorkspace As Object
Dim ParametersGetDb() As String = {"", m_UserMailFile}
Dim ParametersEditDoc() As Object = {"True", ""}
'get the email addresses
For i = 1 To Recipient.Count
Addresses.Append(Recipient.Item(i))
Addresses.Append(",")
Next
'start a new Notes Session
m_DominoSession = Nothing
NotesSession = CreateObject("Notes.NotesSession")
'get the user notes database
If Not (NotesSession Is Nothing) Then
NotesDb = CallByName(NotesSession, "GetDatabase", CallType.Method, ParametersGetDb)
'open user mail database
If Not (NotesDb Is Nothing) Then
CallByName(NotesDb, "OpenMail", CallType.Method)
'create new document
NotesDoc = CallByName(NotesDb, "CreateDocument", CallType.Method)
If Not (NotesDoc Is Nothing) Then
'set some parameters
CallByName(NotesDoc, "Form", CallType.Set, "Memo")
CallByName(NotesDoc, "SendTo", CallType.Set, Addresses.ToString)
ParametersEditDoc.SetValue(NotesDoc, 1)
'create a NotesUIWorkspace
NotesWorkspace = CreateObject("Notes.NotesUIWorkspace")
'open the new memo previously created
If Not (NotesWorkspace) Is Nothing Then
CallByName(NotesWorkspace, "EditDocument", CallType.Method, ParametersEditDoc)
NotesSession = Nothing
NotesDb = Nothing
NotesDoc = Nothing
NotesWorkspace = Nothing
Addresses = Nothing
Return True
End If
End If
End If
End If
End Function
 
Somehow, deleting the NotesWorkspace strikes me as bad form for Notes.
I don't recall ever doing that in LotusScript, nor can I imagine a scenario which would justify it technically.
If you REM the line "NotesWorkspace = Nothing", do you still get the error ?

Pascal.
 
Thanks for the reply Pascal. It's actually throwing the exception before this point. When I step throught the code and run the line:
CallByName(NotesWorkspace, "EditDocument", CallType.Method, ParametersEditDoc)
It runs and does open the new memo in edit mode with the address field populated, but throws this extra 'exception' afterwards, so doesn't actually run the next line:
NotesSession = Nothing
However, since the whole code runs fine for me as a 'Notes Administrator' I think the NOtesWorkspace = Nothing seems to work ok. The Notes Administrator status is the only thing I can see which is different between users trying to run this as System Admins with Full Permissions at file level have the same problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top