Solved

Lotus notes in Visual basic: GetDatabase

Posted on 2004-08-08
6
2,027 Views
Last Modified: 2013-11-25
The following is visual basic code for Lotus Notes.

My users have two emails account in their Lotus Notes. I want my program to launch the account that can send external email. How can I specify that the particular Notes database is used?

In the notes property of the database, I found:

Server:
NS1BK11/SRV/DBG

Filename:
mail/kflee.nsf

But my code doesn't work, Lotus Notes cannot send the email, probably because the value after
Set OLEDB = OLESess.GetDatabase
is incorrect.

Any Idea?

    Dim OLESess As Object
    Dim OLEDB As Object
    Set OLESess = CreateObject("Notes.Notessession")
    Set OLEDB = OLESess.GetDatabase("NS1BK11/SRV/DBG", "mail\kflee.nsf") <========
    With OLEDB
        .OPENMAIL
        If Not .IsOpen Then
            MsgBox ("Unable to open Notes session. Sorry, you have to send mannually.")
            Exit Function
        End If
    End With

    On Error GoTo NotesError
    Const EMBED_ATTACHMENT = 1454
    ' Creates a new document/message.
    Dim Doc As Object
    Dim NItem As Object
    Set Doc = OLEDB.CreateDocument
    With Doc
        ' creates body of message and populates headers
        Set NItem = Doc.CreateRichTextItem("BODY")
        .Form = "Memo"
        .Subject = MySubject
        .SendTo = MySendTo
        .CopyTo = MyCopyTo
        .Body = MyBody
        .postdate = Date
        .SaveMessageOnSend = True
        .PostedDate = Now
        Call NItem.EmbedObject(EMBED_ATTACHMENT, "", MyAttach)
        .Send False
    End With

    On Error Resume Next
    Set OLEDB = Nothing
    Set OLESess = Nothing
    Exit Function
0
Comment
Question by:leekf
6 Comments
 
LVL 34

Expert Comment

by:flavo
ID: 11749699
I never used lotus notes before (i use Groupwise)

but i have seen an example using

Set OLEDB = OLESess.GETDATABASE("", MailDbName)

where MailDbName = THe current users notes mail database name

and this

   Set objDB = objSession.GETDATABASE("", "names.nsf")

So im thinking you many not need to pass the server name "NS1BK11/SRV/DBG"  ???  no-one else seems to.

Hope this helps...

Dave
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 11750338
I always recommend using early binding by setting a reference to Lotus Domino Objects

There are some examples using early and late binding to read notes mail here:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20445195.html?query=Session.Initialize&clearTAFilter=true
0
 
LVL 14

Expert Comment

by:aelatik
ID: 11750490
Just remove the "        .OPENMAIL" line.
When you use GetDatabase it already opens the database and .OpenMail will only cause problems.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12503616
PAQed - no points refunded (of 125)

modulo
Community Support Moderator
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using "ScreenUpdating" 6 63
windbg taking it's time 32 90
MS SQL store procedure to calculate and return result 6 56
Protecting vb6 & .Net code Obfuscation 18 121
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now