Lotus Notes - Opening database

BigJimSlade

Registered User.
Local time
Today, 19:29
Joined
Oct 11, 2000
Messages
173
Hi, Big Jim here:

I am attempting to open a Lotus Notes database using VBA. Here is part of my code:

Dim session As Object
Dim db As Object
Dim doc As Object

Set session = CreateObject("Notes.NotesSession")
Set db = session.GetDatabase("", "")
Do Until db.IsOpen = True
db.OPENMAIL
Loop
Set doc = db.CreateDocument

Problem is, db.IsOpen never evaluates to true. If I take the Loop out, I get Error 7063 telling me that the database is not open. I know it is open, because I opened it. This is a new error, as I have run my code before without a problem. Any idea what could have happened with Lotus Notes that would cause this error?

Thanks in advance

Big Jim
 
Jim,
Are you trying to open Lotus to send email or are you trying to open one of the Lotus tables on the server?

Scott
 
Hi Scott,

I am just trying to send an Email.

Thanks for replying.

Big Jim
 
Jim,
Here is the code I use to send with Lotus Notes 5.0
Code:
Function SendLotus()
                  Dim S As Object
                  Dim db As Object
                  Dim doc As Object
                  Dim rtItem As Object
                  Dim LIST1(1 To 9) As String 'add a greater range to send more
                  Dim Server As String, Database As String
                  Dim strError As String

                  LIST1 = Array("1stEmail@address.com", "2ndEmail2address.com","etc...")

                 ' start up Lotus Notes and get object handle
                  Set S = CreateObject("Notes.NotesSession")
                  Server = S.GETENVIRONMENTSTRING("MailServer", True)
                  Database = S.GETENVIRONMENTSTRING("MailFile", True)
                  Set db = S.GETDATABASE(Server, Database)

                  On Error GoTo ErrorLogon
                  ' See if user is logged on yet;
                  ' if not, the error handler will
                  ' kick in!
                  Set doc = db.CREATEDOCUMENT
                  On Error GoTo 0

                  doc.Form = "Memo"
                  doc.Importance = "1" '(WHERE 1=URGENT, 2= NORMAL, 3=FYI)
                  

                  'Send an EMail to
                  doc.SENDTO = (LIST1)
                  'SENDS A RETURN RECIEPT
                  'doc.RETURNRECIEPT = "1"
                  doc.Subject = "Enter your subject here"
                  
                  ' this will build the text part of your mail message

                  Set rtItem = doc.CREATERICHTEXTITEM("Body")
                  Call rtItem.APPENDTEXT("Put body of email message here")
                  Call rtItem.ADDNEWLINE(1)
                    'doc.SaveMessageOnSend = True      'to Save in Sent Folder
                  Call doc.send(False) 'Make sure this parameter stays false

                  ' set all object handles to nothing to release memory
                  Set doc = Nothing
                  Set db = Nothing
                  Set S = Nothing
                  Set rtItem = Nothing

               
                  'MsgBox "Mail has been sent!", vbInformation

                  Exit Function

ErrorLogon:
                  If Err.NUMBER = 7063 Then
                  MsgBox "Please login to Lotus Notes first!", vbCritical
                  Set doc = Nothing
                  Set db = Nothing
                  Set S = Nothing
                  Set rtItem = Nothing
                
                  Exit Function
                  Else
                  strError = "An Error has occurred on your system:" & vbCrLf
                  strError = strError & "Err. Number: " & Err.NUMBER & vbCrLf
                  strError = strError & "Description: " & Err.Description
                  MsgBox strError, vbCritical
                  Set doc = Nothing
                  Set db = Nothing
                  Set S = Nothing
                  Set rtItem = Nothing
                
                  Exit Function
                  End If

Hope this helps
Scott
 
This code works great but what is the property called where I can edit the "from" line? I want to be able to set it so it comes from say, "ClientServices@yourcompany.com" instead of being from the person that's running it.
 
Not sure, I never had to change the From: address. I didn't see anything in the object browser that relates to that field.
 

Users who are viewing this thread

Back
Top Bottom