Solved

Sending Mail to Lotus Notes

Posted on 1998-11-02
9
528 Views
Last Modified: 2012-05-04
I need my VB Application to send a reminder email through our Lotus Notes email environment. Is there a way to programmitically set VB to do it? If so, please provide a code example. Thanks!
0
Comment
Question by:sehenkel
  • 5
  • 3
9 Comments
 
LVL 3

Expert Comment

by:jjmartin
Comment Utility
This can be done.  I don't have the code on me right now, but I will post that tomorrow morning.
0
 
LVL 13

Expert Comment

by:Mirkwood
Comment Utility
Multiple ways.
You can use the MAPI control since notes is MAPI complaint or you can do it directly with notes.


Reference the Lotus Notes automation classes to your project and you will get complete control over notes.
0
 

Author Comment

by:sehenkel
Comment Utility
Is it the NOTES32.TLB file? If so, could you provide me w/ some example code or some reference locations to use the Notes Automation classes?
0
 
LVL 3

Accepted Solution

by:
jjmartin earned 100 total points
Comment Utility
The following code will email using you existing Lotus Notes.  Lotus Notes must be installed in teh machine, and in your project you must make reference to the Lotus Notes Automation Classes.  If Lotus Notes is not up at the time this is executed, it will bring up LN and prompt the user for their password.  Question for you thought; why can't you set up a Lotus Notes agent to send the email automatically?

'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 = "PHX_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("PHX_SHR_NOTES03/American Express", "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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:sehenkel
Comment Utility
Ok, I tried the code and I get a runtime error 429:" Active X component can't create object."

When debugging, this is the line that has the problem:

Set NOTESSESSION = CreateObject("Notes.NotesSession")

Now I placed the NOTES32.TLB file in the program references. Is there anything else I need to do? Thanks in advance.
0
 

Author Comment

by:sehenkel
Comment Utility
Ok, I tried the code and I get a runtime error 429:" Active X component can't create object."

When debugging, this is the line that has the problem:

Set NOTESSESSION = CreateObject("Notes.NotesSession")

Now I placed the NOTES32.TLB file in the program references. Is there anything else I need to do? Thanks in advance.
0
 
LVL 3

Expert Comment

by:jjmartin
Comment Utility
Give this a try, I confirmed that it is working on my PC.

Private Sub Command1_Click()
' Under Project|References, you must check the references to Lotus Notes Automation Classes
Set NOTESSESSION = CreateObject("Notes.NotesSession")
'The first set of quotes contains the database location, the second set contains the nsf file for the
'individual user.  This is specific for each user.  In a full fledged application, I save that in an
'ini file that is read in at run time.
Set NOTESDATABASE = NOTESSESSION.GetDatabase("PHX_SHR_NOTES03/American Express", "MAIL\jmartin.nsf")
Set NOTESDOCUMENT = NOTESDATABASE.CreateDocument
Set NotesRichText = NOTESDOCUMENT.CreateRichTextItem("Body")

NOTESDOCUMENT.Subject = "Testing"
NOTESDOCUMENT.Body = "Attached file is here"
NOTESDOCUMENT.SendTo = "Jason J Martin"
NOTESDOCUMENT.savemessageonsend = True
NOTESDOCUMENT.send False

End Sub

0
 

Author Comment

by:sehenkel
Comment Utility
Same problem. Its the following line that's causing a problem:

Set NOTESSESSION = CreateObject("Notes.NotesSession")


Any other thoughts??
0
 

Author Comment

by:sehenkel
Comment Utility
I had to run the NOTESW32.REG file and the code worked perfectly. Thanks for all of your help!!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 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

15 Experts available now in Live!

Get 1:1 Help Now