Help!!!
I`ve written a program in VB to connect to my Domino server and compose a new Lotus Notes Memo. I think the code is right as the memo is created however the document object does not seem to return a value and i get a "-2147417851 Automation error, The server threw an exception." error.
I need to return the document id as i want to add an attachment to it later...
here is the code
------------------------------------------------------------
Option Explicit
Public Sub connecttolotus(ServerName As String)
On Error GoTo Error_Trap
Dim ws As Object
Dim uidoc As Object
Dim AttachME As Object
Dim EmbedObj As Object
Dim NewMdName As String
Dim NotesSession As Object
Dim NotesUsername As String
Dim Attachment As String
Dim MailDbName As String
Dim MailCounter As Integer
Set NotesSession = CreateObject("Notes.NotesSession"
NotesUsername = NotesSession.USERNAME
Attachment = "c:\as400.log" ' add an attachment filename
NewMdName = "" ' initialise the username file
'Get the engineer username and then calculate the mail file name
MailDbName = Mid$(NotesUsername, 4, 1) & Right$(NotesUsername, (Len(NotesUsername) - InStr(1, NotesUsername, " "))
For MailCounter = 1 To Len(MailDbName)
If Mid(MailDbName, MailCounter, 1) <> "/" Then
NewMdName = NewMdName & Mid(MailDbName, MailCounter, 1)
Else
Exit For
End If
Next MailCounter
MailDbName = "mail\" & NewMdName & ".nsf"
' Connect to Lotus Notes and Compose Document
Set ws = CreateObject("Notes.NotesUIWorkspace"
Set uidoc = CreateObject(ws.COMPOSEDOCUMENT(ServerName, MailDbName, "Memo", 10, 10))
'Add the attachment
Set AttachME = uidoc.CREATERICHTEXTITEM("Attachment"
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment"
uidoc.CREATERICHTEXTITEM ("Attachment"
'Refresh the Window
uidoc.RELOAD
End
Exit Sub
Error_Trap:
'Trap any Errors
MsgBox ("Error : " & Err.Number & " " & Err.Description)
Resume Next
End Sub
I`ve written a program in VB to connect to my Domino server and compose a new Lotus Notes Memo. I think the code is right as the memo is created however the document object does not seem to return a value and i get a "-2147417851 Automation error, The server threw an exception." error.
I need to return the document id as i want to add an attachment to it later...
here is the code
------------------------------------------------------------
Option Explicit
Public Sub connecttolotus(ServerName As String)
On Error GoTo Error_Trap
Dim ws As Object
Dim uidoc As Object
Dim AttachME As Object
Dim EmbedObj As Object
Dim NewMdName As String
Dim NotesSession As Object
Dim NotesUsername As String
Dim Attachment As String
Dim MailDbName As String
Dim MailCounter As Integer
Set NotesSession = CreateObject("Notes.NotesSession"
NotesUsername = NotesSession.USERNAME
Attachment = "c:\as400.log" ' add an attachment filename
NewMdName = "" ' initialise the username file
'Get the engineer username and then calculate the mail file name
MailDbName = Mid$(NotesUsername, 4, 1) & Right$(NotesUsername, (Len(NotesUsername) - InStr(1, NotesUsername, " "))
For MailCounter = 1 To Len(MailDbName)
If Mid(MailDbName, MailCounter, 1) <> "/" Then
NewMdName = NewMdName & Mid(MailDbName, MailCounter, 1)
Else
Exit For
End If
Next MailCounter
MailDbName = "mail\" & NewMdName & ".nsf"
' Connect to Lotus Notes and Compose Document
Set ws = CreateObject("Notes.NotesUIWorkspace"
Set uidoc = CreateObject(ws.COMPOSEDOCUMENT(ServerName, MailDbName, "Memo", 10, 10))
'Add the attachment
Set AttachME = uidoc.CREATERICHTEXTITEM("Attachment"
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment"
uidoc.CREATERICHTEXTITEM ("Attachment"
'Refresh the Window
uidoc.RELOAD
End
Exit Sub
Error_Trap:
'Trap any Errors
MsgBox ("Error : " & Err.Number & " " & Err.Description)
Resume Next
End Sub