Link to home
Start Free TrialLog in
Avatar of G Scott
G ScottFlag for United States of America

asked on

VBA to Lotus Notes Calendar entry issue

Hello,

I found some code on EE that works great with one small exception. Each time I click the button to add the calendar entry it prompts me for my email password. Is there any way to code that in?  Here is the code I found:

 
Const Subject = "September staff meeting (Tuesday the ninth)"
    Const position = "9/9/2009 10:00 AM"
    Dim s As New NotesSession
    s.Initialize
    Dim dir As NotesDbDirectory
    Dim db As NotesDatabase
    Set dir = s.GetDbDirectory("")
    Set db = dir.OpenMailDatabase
    MsgBox db.Title & " on " & db.Server, , db.FilePath
    Dim doc As Object 'notesDocument
    Set doc = db.createDocument
    doc.replaceItemvalue "Form", "Appointment"
    Dim dateTime As Object 'NotesDateTime
    Set dateTime = s.createDateTime(position)
    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", "3"
    doc.replaceItemvalue "Alarms", "1"
    doc.replaceItemvalue "startDate", dateTime
    doc.replaceItemvalue "endDate", dateTime
    doc.replaceItemvalue "endTime", dateTime
    doc.Save True, True
    doc.putInFolder "($Alarms)"

Open in new window


Thanks for any help you can give me.
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of G Scott

ASKER

sjef bosman, nope you are not too late, in fact, I was hoping to hear from you since you may recognize the code. ;)  

How exacly do you modify the Initialize to include the password??  Sorry, kinda new to VBA.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of G Scott

ASKER

Thanks! That worked great!!
Avatar of G Scott

ASKER

One interesting thing about that code maybe someone can help. When I click on it on my calendar it says "Error trying to open document: Note item not found" AND it does't get replicated. Any thoughts?
About the error: no clue at all... You could try to run the debugger to find out where the error comes from.

The document isn't replicated? There isn't a replication formula present for the database? No Readers fields in the document? Then it *should* replicate...