Solved

Using Lotus Notes with VB

Posted on 2000-02-21
2
184 Views
Last Modified: 2010-05-02
I am trying to use lotus notes from a vb6 application, but with little luck.  I have already tried the MAPI control but it only gets as far as

Session.SignOn

then asks to set outlook as the default mail client.
0
Comment
Question by:jameskennedy
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 150 total points
ID: 2541876
The following code is posted with full respect to Waty who supplied it to me in the first place.

' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : waty.thierry@usa.net
' * Date             : 7/07/99
' * Time             : 12:48
' **********************************************************************
' * Comments         : Create Attachment file in Lotus Notes
' *
' *
' **********************************************************************

Public Function CreateAttachment(DBName As String, DocId As String, AttachmentPath As String) As Boolean

   Dim session As Object
   Dim db As Object
   Dim doc As Object
   Dim Ob As Object
   Dim rtitem As Object 'NotesRichTextItem
   Set session = CreateObject("Notes.NotesSession")
   Set db = session.GetDatabase("", DBName)
   Set doc = db.GetDocumentByUNID(DocId)
   Set rtitem = doc.CreateRichTextItem("Attachment")
   Set Ob = rtitem.EmbedObject (EMBED_ATTACHMENT, "", AttachmentPath)
   Call doc.Save(True, False)
   Dim ws As Object
   Set ws = CreateObject("Notes.NotesUIWorkspace")
   Call ws.EditDocument(True, doc)

End Function

' #VBIDEUtils#************************************************************
' * Programmer Name  : David Henderson
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : waty.thierry@usa.net
' * Date             : 09/09/1999
' * Time             : 13:57
' **********************************************************************
' * Comments         : Sending a mail message to Lotus Notes
' *
' * declare objects for notes objects
' *
' **********************************************************************
Dim session As Object, db As Object, doc As Object, rtobject As Object
Dim rtitem As Object

Dim user As String, server As String, mailfile As String

Rem get a handle to a notes session
Set session = CreateObject("notes.notessession")

user = session.UserName
server = session.GetEnvironmentString("MailServer", True)
mailfile = session.GetEnvironmentString("MailFile", True)
Set db = session.getdatabase(server, mailfile)
Set doc = db.createdocument()    doc.Form = "Memo"
'    doc.SendTo = "david henderson@sehe.com"    doc.sendto = txtTo
'    doc.Subject = "notes mail created from vb"    doc.subject = txtSubject
'   the following lines are only needed when attaching files
'Set rtitem = doc.CreateRichTextItem("body")    doc.body = txtBody

Call doc.Send(False)'   clean up after ourselves    Set session = Nothing
Set db = Nothing    Set doc = Nothing

0
 

Author Comment

by:jameskennedy
ID: 2541967
Top notch.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 …
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

18 Experts available now in Live!

Get 1:1 Help Now