Solved

Sending Mail to Lotus Notes

Posted on 1998-11-02
9
532 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
ID: 1442954
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
ID: 1442955
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
ID: 1442956
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
ID: 1442957
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:sehenkel
ID: 1442958
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
ID: 1442959
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
ID: 1442960
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
ID: 1442961
Same problem. Its the following line that's causing a problem:

Set NOTESSESSION = CreateObject("Notes.NotesSession")


Any other thoughts??
0
 

Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

914 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

12 Experts available now in Live!

Get 1:1 Help Now