Using Lotus Notes within VB

I was just wondering if it is possible to use Lotus Notes email from within VB.  I am currently using the Outlook object model (which works fine), but I can't find any method to use Lotus.  I have been advised that I may need to buy the Lotus Developers Kit, but I can't find any good documentation on this subject.  I would appreciate hearing from anyone who knows if it is possible to do this.
LVL 1
justinhemphillAsked:
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.

jjmartinCommented:
The following code will email using you existing Lotus Notes.  Lotus Notes must be installed in the machine, and in your project you must make reference to the Lotus Notes Automation Classes (Project | References).  If Lotus Notes is not up at the time this is executed, it will bring up LN and prompt the user for their password.

'Email the information to the selected contact person
Private Sub cmdEmail_Click()

    Dim Resp As Integer
    Dim Server As String
    Dim UserDef As String
    Dim DefFile As String
    Dim NOTESSESSION As Object
    Dim NOTESDATABASE As Object
    Dim NOTESDOCUMENT As Object
    Dim NotesRichText As Object
     
    'Each person will have to have a different user definition file to access their Lotus Notes email.
    'This is kept in a text file or ini file for easier change and update.
    DefFile = App.Path + "\userdef.txt"
    Open DefFile For Input As #1
         Input #1, Server, UserDef
    Close #1
     
    'This is an example of what the definitions need to look like.
    'Server = "MY_SHR_NOTES03/Blah Blah"
    'UserDef = "MAIL\jmartin.nsf"


            'Here is where we tag into the Lotus Notes email system to send the email.
            Set NOTESSESSION = CreateObject("Notes.NotesSession")
            Set NOTESDATABASE = NOTESSESSION.GETDATABASE(Server, UserDef)
            'This is an example of what this looks like without the variables.
            'Set NotesDatabase = NotesSession.GetDatabase("MY_SHR_NOTES03/MyMail", "MAIL\jmartin.nsf")
            Set NOTESDOCUMENT = NOTESDATABASE.CREATEDOCUMENT
            Set NotesRichText = NOTESDOCUMENT.CREATERICHTEXTITEM("Body")

            NOTESDOCUMENT.Subject = txtSubject.Text 'This is the subject of the email an appears in the subject line
            NOTESDOCUMENT.Body = txtMessage.Text   'This is the actual message of the email
            NOTESDOCUMENT.SendTo = Email(lstNames.ListIndex)    'Here is the email address of the person your emailing to.
            NOTESDOCUMENT.SAVEMESSAGEONSEND = False 'This has to be set to False or we get errors
            NOTESDOCUMENT.SEND False    'Keep this set to false.

     
End Sub
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
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
Visual Basic Classic

From novice to tech pro — start learning today.