• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 570
  • Last Modified:

Sending Mail to Lotus Notes

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
sehenkel
Asked:
sehenkel
  • 5
  • 3
1 Solution
 
jjmartinCommented:
This can be done.  I don't have the code on me right now, but I will post that tomorrow morning.
0
 
MirkwoodCommented:
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
 
sehenkelAuthor Commented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jjmartinCommented:
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
 
sehenkelAuthor Commented:
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
 
sehenkelAuthor Commented:
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
 
jjmartinCommented:
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
 
sehenkelAuthor Commented:
Same problem. Its the following line that's causing a problem:

Set NOTESSESSION = CreateObject("Notes.NotesSession")


Any other thoughts??
0
 
sehenkelAuthor Commented:
I had to run the NOTESW32.REG file and the code worked perfectly. Thanks for all of your help!!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now