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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COMPOSEDOCUMENT - Automation Error

Status
Not open for further replies.

JonEvans

Technical User
Aug 16, 2001
3
GB
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) <> &quot;/&quot; Then
NewMdName = NewMdName & Mid(MailDbName, MailCounter, 1)
Else
Exit For
End If
Next MailCounter
MailDbName = &quot;mail\&quot; & NewMdName & &quot;.nsf&quot;
' Connect to Lotus Notes and Compose Document
Set ws = CreateObject(&quot;Notes.NotesUIWorkspace&quot;)
Set uidoc = CreateObject(ws.COMPOSEDOCUMENT(ServerName, MailDbName, &quot;Memo&quot;, 10, 10))

'Add the attachment
Set AttachME = uidoc.CREATERICHTEXTITEM(&quot;Attachment&quot;)
Set EmbedObj = AttachME.EMBEDOBJECT(1454, &quot;&quot;, Attachment, &quot;Attachment&quot;)
uidoc.CREATERICHTEXTITEM (&quot;Attachment&quot;)

'Refresh the Window
uidoc.RELOAD
End
Exit Sub


Error_Trap:
'Trap any Errors
MsgBox (&quot;Error : &quot; & Err.Number & &quot; &quot; & Err.Description)
Resume Next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top