Solved

Lotus notes in Visual basic: GetDatabase

Posted on 2004-08-08
6
2,068 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

688 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