Solved

Using Lotus Notes with VB

Posted on 2000-02-21
2
200 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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.
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…
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now