Solved

Lotus notes in Visual basic: GetDatabase

Posted on 2004-08-08
6
2,006 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

706 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

19 Experts available now in Live!

Get 1:1 Help Now