Basic Lotus Notes Email VBA Programming Question

Not familiar at all with Lotus notes.  I am writting code to create email messages from MS Access to send out via Lotus Notes with attachments.  Everything works fine except that the client wants to send the emails from an email box other than their own.  The key portion of the code is as follows

Dim mailbox As Object
Dim session As Object
Dim db As Object

Set session = CreateObject("notes.notessession")

Set db = session.GetDatabase("", "dog")

'OPEN THE MAIL DATABASE
If db.IsOpen = True Then
'nothing
Else
Call db.OPENMAIL
End If

'CREATE THE NEW DOCUMENT
Set MailDoc = db.CreateDocument

'APPEND SUBJECT
Call MailDoc.AppendItemValue("Subject", sSubject)

'SET DOCUMENT FORMAT TO MEMO
Call MailDoc.AppendItemValue("Form", "Memo")

'APPEND RECIPIENT
Call MailDoc.AppendItemValue("SendTo", sRecipient)

'CREATE MEMO BODY
Set rtItem = MailDoc.CreateRichTextItem("Body")
Set rtStyle = session.CreateRichTextStyle

'Save as draft instead of send
Call MailDoc.Save(True, True)


The problem seems to be with the
GetDatabase("", "gmcc") line of code.

if I use Getdatabase("","")  it creates the email just fine in their default email draft folder.
If I use GetDatabase("", "Dog") it created the email just fine in the email box called Dog on their local machine.

My problem is that regardless of what I put in the first parameter of GetDatabase as the server name, it ignores it and sends the email from the default email box.  

How do I find the value to put in the first parameter so that it used the server not the local database?  I have a lot of programming experience, but nearly no Lotus notes experience.  Is there a way using some vba code added to what i have already above to get it to tell me the server name or is there some thing I can look at in Notes iteslf to ge the value.  I have tried going to the file preferences and the mailbox database properties dialogs and tried using all the values there to no avail.  I am guessing there is an easy solution if you know how to do it.

thanks

Gary Dearing
gdearing@msn.com


GaryDearingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbonaciCommented:
If the user is working locally OpenMail opens his local replica, if not it opens server replica of mail db.
You can use server property of database object:

To get: serverName$ = notesDatabase.Server

If the database is on a workstation, the property returns an empty string ("").
The database does not need to be open to use this property.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mbonaciCommented:
Here's a piece of code that opens mail db by reading environment settings (notes.ini).
mailsvr = oSess.GetEnvironmentString("MailServer", True)
	mailfile = LCase(oSess.GetEnvironmentString("MailFile", True))

	Set oMailDB = oSess.GETDATABASE("", "")
	Call oMailDB.open(mailsvr, mailfile)

	If oMailDB.isopen Then
		Set oMailDoc = oMailDB.CREATEDOCUMENT
	Else
		MsgBox "Could not open Notes", 32
	End If

Open in new window

0
Sjef BosmanGroupware ConsultantCommented:
What you describe is right but your conclusion and premisses are wrong.

> The problem seems to be with the GetDatabase("", "gmcc") line of code.
Wrong assumption.

> if I use Getdatabase("","")  it creates the email just fine in their default email draft folder.
Correct.

> If I use GetDatabase("", "Dog") it created the email just fine in the email box called Dog on their local machine.
Correct.

> My problem is that regardless of what I put in the first parameter of GetDatabase
> as the server name, it ignores it and sends the email from the default email box.  
Wrong assumption.

Three cases:
A. GetDatabase("","")
B. GetDatabase("","Dog")
C. GetDatabase("server","file")

and your code is:

      Set db = session.GetDatabase("x", "y")

      'OPEN THE MAIL DATABASE
      If db.IsOpen = True Then
            'nothing
      Else
            Call db.OPENMAIL
      End If

Now what happens in each of the cases A, B and C?
A. with "empty" parameters; only a NotesDatabase object is created nothing else; consequently, IsOpen will return False so OpenMail is called and the current user's mail database is opened.
B. no server, only a database; now, a NotesDatabase object is created and the local file is opened IF the user has access rights to that database. If the user doesn't have access, IsOpen will return false and (again) the current user's mail database is opened.
C. server and database; again, a NotesDatabase object is created and the server's file is opened IF the user has access rights to that server AND database. If the user doesn't have access, IsOpen will return false and (again) the current user's mail database is opened. The server must exist AND the user should also have the right to access the server.

Ask an Admin for the correct server name.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.