Can anyone help, I am trying to compose a new memo from VB connecting to my Domino server. I`m pretty sure i`ve got the code right as it does actually create the memo form ready to send, however the code then returns a "-2147417851 Automation error. The server threw and exception".
My problem is that I then want to attach a document to the email before allowing the user to add any recipients on the Lotus Memo.
This is the code i`ve written so far...
*********************************************************
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
My problem is that I then want to attach a document to the email before allowing the user to add any recipients on the Lotus Memo.
This is the code i`ve written so far...
*********************************************************
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