MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Excel mail to Lotus Notes


Posted by Jugge on April 27, 2001 3:15 AM

Hello.

I have this code in Excel vba when i was running Outlook.
But now i have gone over to Lotus Notes 5.0.5 and now
this vb not working. Can anyone help me.

Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
With objMail
.To = "Donald.duck@disney.com"
.Subject = "Hello"
.Body = "Here is the file"
.Attachments.Add "C:\temp\donald.doc"
.Send
End With
Set objMail = Nothing
Set objOL = Nothing

/Jugge


Posted by Ivan Moala on April 27, 2001 9:08 AM


you will need to reference the notes Olb and use
code similar to this example;

Sub LotusNotes_Session()
Dim Subject As String
Dim Recipient As String
Dim Msg As String
Dim nSession As notesSession
Dim nDatabase As NotesDatabase
Dim nDoc As NOTESDOCUMENT

Subject = "Test message from VBA"
Recipient = "me@here.com.nz"
Msg = "This is a message sent to myself from VBA." + _
vbNewLine + "blah"

'session and database declared in general as object
Set nSession = CreateObject("Notes.NotesSession") 'create notes session
Set nDatabase = nSession.GetDatabase("", "") 'set db to database not yet named
Call nDatabase.OPENMAIL 'Open the users mail database

Set nDoc = nDatabase.CREATEDOCUMENT 'create a new document in mail database
Call nDoc.replaceitemvalue("SendTo", Recipient) 'create sendto field
Call nDoc.replaceitemvalue("Subject", Subject) 'create subject field
Call nDoc.replaceitemvalue("Body", Msg) 'create body field
Call nDoc.SEND(False) 'send message

Set nSession = Nothing ' close connection to free memory

End Sub


Notes from help file;
Set nDatabase = nSession.GetDatabase( server$, dbfile$ [, createonfail ] )

Parameters
server$

String. The name of the server on which the database resides. Use an empty string ("") to indicate a database on the current computer: if the script runs on the workstation, the empty string indicates a local database; if the script runs on a server, it indicates a database on that server.


dbfile$

String. The file name and location of the database within the Notes data directory. Use empty strings for both dbfile$ and server$ if you want to open the database later. Use a full path name if the database is not within the Notes data directory.

createonfail

Note This parameter is new with Release 5.

Boolean. Optional. Specify True (default) to create the database if it does not exist.


Return value
NotesDatabase

A NotesDatabase object that can be used to access the database you've specified.


If a database exists at the server$ and dbfile$ specified, the NotesDatabase object is open, and the script can access all its properties and methods.

If a database does not exist at the server$ and dbfile$ specified, the NotesDatabase object is closed. To create a new database at the specified location if one does not exist, specify True for createonfail.

Ivan