sending Lotus Notes appiontment with MS Access

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
    'Session.Initialize
    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
        Else
        maildb.OPENMAIL
    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
drakebcbsksAsked:
Who is Participating?
 
rockiroadsCommented:
see this post, it mentions a problem with dates. Now I dont know if its applicable to you, but have a look

http://www.fabalou.com/VBandVBA/lotusnotesappointment_ver6.asp

Do the dates have to be in a certain format?
0
 
drakebcbsksAuthor Commented:
I finally figured it out.  Within that post there was reference to Joe Korzeniewski of www.vortexwd.net.  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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.