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
Solved

Lotus notes in Visual basic: GetDatabase

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bit defender blocks good applications 2 101
Added a column screws up code 5 63
Authentication of Web Services 3 89
VIDEO DATASOURCE Control Resize issue 2 30
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.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

856 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