To anyone who can help or he has the same issue,
At work we use lotus notes. I created an access database that will send data from the database to anyone while your lotus notes is running.
I got the code to send out e-mails using notes from another thread and everything works fine. The only problem I have is when it gets into my mailbox the following message pops up:
"A stored form can not contain computed subforms"
It will pop up a couple of times before I can read the e-mail. Is there anything I'm doing wrong or is this a bug in Lotus Notes? Is there a way for me to eliminate this?
I appreciate your help. Below is the code I used to compile the info to be send out and below that I have posted the code for the module that uses notes to send it.
===========================================================
For Each var In ListSend.ItemsSelected
strList = ListSend.ItemData(var)
recip(intnum) = strList
intnum = intnum + 1
Next var
Dim stBody As String
stBody = stBody & "File Number:" & vbCr
stBody = stBody & "==========================" & vbCr
stBody = stBody & Forms!SOInfo.SONUM & vbCr & vbCr
stBody = stBody & "Type:" & vbCr
stBody = stBody & "==========================" & vbCr
stBody = stBody & Forms!SOInfo.LSOTYPE & vbCr & vbCr
If Forms!SOInfo.DEPT <> "" Then
stBody = stBody & "Department:" & vbCr
stBody = stBody & "==========================" & vbCr
stBody = stBody & Forms!SOInfo.DEPT & vbCr & vbCr
End If
SendNotesMail "Safety Observation #" & Forms!SOInfo.SONUM, "", recip, "", stBody, True
===========================================================
Sub SendNotesMail(Subject As String, Attachment As String, Recipient As Variant, cc As String, BodyText As String, SaveIt As Boolean)
'Set up the objects required for Automation into lotus notes
Dim MailDb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself NotesDocument
Dim MailDoc2 As Object
Dim AttachME As Object 'The attachment richtextfile object
Dim session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim CurrentDatabase As String
Dim NotesSS As Object
Dim NotesDb As Object
On Error GoTo Errshow:
Set NotesSS = CreateObject("Notes.NotesSession")
With NotesSS
Set NotesDb = .GETDATABASE("WAKEAM3/WYP", "mail\721116.nsf")
End With
With NotesDb
'Start a session to notes
Set session = CreateObject("Notes.NotesSession")
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = session.UserName
MailDbName = NotesDb.FileName
Set MailDb = session.GETDATABASE("", MailDbName)
If Not (MailDb.ISOPEN) = True Then MailDb.OPENMAIL
'Set up the new mail document
Set MailDoc = MailDb.CREATEDOCUMENT
With MailDoc
.Form = "Memo"
.sendto = Recipient
.CopyTo = cc
.Subject = Subject
.body = BodyText
.SAVEMESSAGEONSEND = SaveIt
End With
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
End With
'Send the document
MailDoc.send 1, Recipient
MsgBox "A copy of the Observation has been sent.", vbOKOnly, "Observation Sent"
Cleanup:
Set MailDb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set session = Nothing
Set EmbedObj = Nothing
Exit Sub
Errshow:
If Err.Number = 7063 Then
MsgBox "You have not logged onto Lotus Notes. Please log on and try to send again."
Else
MsgBox (Err.Description)
End If
GoTo Cleanup
End Sub
At work we use lotus notes. I created an access database that will send data from the database to anyone while your lotus notes is running.
I got the code to send out e-mails using notes from another thread and everything works fine. The only problem I have is when it gets into my mailbox the following message pops up:
"A stored form can not contain computed subforms"
It will pop up a couple of times before I can read the e-mail. Is there anything I'm doing wrong or is this a bug in Lotus Notes? Is there a way for me to eliminate this?
I appreciate your help. Below is the code I used to compile the info to be send out and below that I have posted the code for the module that uses notes to send it.
===========================================================
For Each var In ListSend.ItemsSelected
strList = ListSend.ItemData(var)
recip(intnum) = strList
intnum = intnum + 1
Next var
Dim stBody As String
stBody = stBody & "File Number:" & vbCr
stBody = stBody & "==========================" & vbCr
stBody = stBody & Forms!SOInfo.SONUM & vbCr & vbCr
stBody = stBody & "Type:" & vbCr
stBody = stBody & "==========================" & vbCr
stBody = stBody & Forms!SOInfo.LSOTYPE & vbCr & vbCr
If Forms!SOInfo.DEPT <> "" Then
stBody = stBody & "Department:" & vbCr
stBody = stBody & "==========================" & vbCr
stBody = stBody & Forms!SOInfo.DEPT & vbCr & vbCr
End If
SendNotesMail "Safety Observation #" & Forms!SOInfo.SONUM, "", recip, "", stBody, True
===========================================================
Sub SendNotesMail(Subject As String, Attachment As String, Recipient As Variant, cc As String, BodyText As String, SaveIt As Boolean)
'Set up the objects required for Automation into lotus notes
Dim MailDb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself NotesDocument
Dim MailDoc2 As Object
Dim AttachME As Object 'The attachment richtextfile object
Dim session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim CurrentDatabase As String
Dim NotesSS As Object
Dim NotesDb As Object
On Error GoTo Errshow:
Set NotesSS = CreateObject("Notes.NotesSession")
With NotesSS
Set NotesDb = .GETDATABASE("WAKEAM3/WYP", "mail\721116.nsf")
End With
With NotesDb
'Start a session to notes
Set session = CreateObject("Notes.NotesSession")
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = session.UserName
MailDbName = NotesDb.FileName
Set MailDb = session.GETDATABASE("", MailDbName)
If Not (MailDb.ISOPEN) = True Then MailDb.OPENMAIL
'Set up the new mail document
Set MailDoc = MailDb.CREATEDOCUMENT
With MailDoc
.Form = "Memo"
.sendto = Recipient
.CopyTo = cc
.Subject = Subject
.body = BodyText
.SAVEMESSAGEONSEND = SaveIt
End With
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
End With
'Send the document
MailDoc.send 1, Recipient
MsgBox "A copy of the Observation has been sent.", vbOKOnly, "Observation Sent"
Cleanup:
Set MailDb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set session = Nothing
Set EmbedObj = Nothing
Exit Sub
Errshow:
If Err.Number = 7063 Then
MsgBox "You have not logged onto Lotus Notes. Please log on and try to send again."
Else
MsgBox (Err.Description)
End If
GoTo Cleanup
End Sub