sending Lotus Notes appiontment with MS Access

Posted on 2006-05-09
Last Modified: 2011-10-03
Maybe this isn't possible, but I'm trying to send a Lotus Notes appointment with the click of a buton in MS Access.  I have a form with one button that runs the function below on click.  When I run the code I get a run-time error '-2147417851 (80010105)':  Automation error The server threw an exception on the line doc.replaceitemvalue "startDateTime", dateTime.  How can I correct this?
FYI.  This code has come from bits and pieces of Q & As I've found.  

Also, if I comment out the lines from doc.replaceitemvalue "startDateTime", dateTime to doc.replaceitemvalue "endTime", dateTime I get a blank email that's sent with this error when you try to open it:  Field 'StartDate_2':  Incorrect data type for operator or @Function:  Time/Date expected.  This will probably be fixed if the above is corrected but may provide more help to my problem.

Public Function SendReminder(Recipient As String, BodyText As String, SaveIt As Boolean)
    Const Subject = "May staff meeting (Tuesday the ninth)"
    Const position = "5/9/2006 10:00 AM"
    Dim maildb As Object 'The mail database
    Dim userName As String 'The current users notes name
    Dim MailDbName As String 'THe current users notes mail database name
    Dim MailDoc As Object 'The mail document itself
    Dim Session As Object 'The notes session
    Dim doc As Object 'notesDocument
    Dim dateTime As Object 'NotesDateTime

    Set Session = CreateObject("Notes.NotesSession")
    userName = Session.userName
    MailDbName = Left$(userName, 1) & Right$(userName, (Len(userName) - InStr(1, userName, " "))) & ".nsf"
    Set maildb = Session.GETDATABASE("", MailDbName)
    'Open the mail database in notes
    If maildb.ISOPEN = True Then
        'Already open for mail
    End If

    Set doc = maildb.createDocument
    Set dateTime = Session.createDateTime(position)
    doc.Form = "Appointment"
    doc.replaceitemvalue "Form", "Appointment"
    doc.replaceitemvalue "$Alarm", 1
    doc.replaceitemvalue "$AlarmOffset", 0
    MsgBox "Setting reminder/alarm - " & dateTime.lslocalTime & " - " & Subject
    doc.replaceitemvalue "startDateTime", dateTime
    doc.replaceitemvalue "endDateTime", dateTime
    doc.replaceitemvalue "calendarDateTime", dateTime
    doc.replaceitemvalue "Subject", Subject
    doc.replaceitemvalue "startTime", dateTime
    doc.replaceitemvalue "appointmentType", "0"
    doc.replaceitemvalue "Alarms", "1"
    doc.replaceitemvalue "startDate", dateTime
    doc.replaceitemvalue "endDate", dateTime
    doc.replaceitemvalue "endTime", dateTime
    doc.Save True, True
    doc.SEND 0, Recipient
    doc.putInFolder "($Alarms)"
    'Clean Up
    Set maildb = Nothing
    Set MailDoc = Nothing
    Set Session = Nothing
End Function
Question by:drakebcbsks
    LVL 65

    Accepted Solution

    see this post, it mentions a problem with dates. Now I dont know if its applicable to you, but have a look

    Do the dates have to be in a certain format?

    Author Comment

    I finally figured it out.  Within that post there was reference to Joe Korzeniewski of  When going to that website, I found some VB code that I used to replace what I had.  It took a small bit of alterations, but it now works perfectly.  Thanks for the post.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    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…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

    737 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