Link to home
Start Free TrialLog in
Avatar of colishau
colishau

asked on

_Send Appointment/Meeting with vb

Gentlemen,

I'd appreciate your help with creating and sending a 'To Do' task item, a 'Meeting' item or an appointment item to a recipient with vb through lotus notes (4 - 6).

I have had no difficulty sending mail, so some simple code examples should be sufficient as a guideline.

Otherwise, I'd like if you could point me in the direction of where I could find information on the relevant objects and properties needed to do this. I have searched the net for hours.

Thanks in advance, Colin.
Avatar of qwaletee
qwaletee

There are no built-in "To Do" or "Meeting" objects, though Lotus does offer an add-on (free, I think) that wrappers the core object model with some simplified messaging/calendaring objects.

Here's an example of creating a reminder, which is almost identical to a meeting:

https://www.experts-exchange.com/questions/20624446/Reminder-Button.html

It uses LotusScript instead of VB, but the only two changes you would need to make are:

1) session must be initialized

2) notesDateTime can't be created via new, and must be created via session methods.

The changed code is:




   Const Subject = "Test reminder subject"
   Const position = "some date or other"

   Dim s As New notesSession
   s.initialize
   Dim db As notesDatabase
   Set db = s.currentDatabase
   Dim doc As notesDocument
   Set doc = db.createDocument
   DOC.FORM = "Appointment" 'THIS IS THE NEW LINE
   Dim dateTime NotesDateTime
   Set dateTime = s.createDateTime( position )
   doc.~$Alarm = 1
   doc.~$AlarmOffset = 0
   Print "Setting reminder/alarm - " dateTime.lslocalTime " - " Subject
   Set doc.startDateTime = dateTime
   Set doc.endDateTime = dateTime
   Set doc.calendarDateTime = dateTime
   doc.Subject = Subject
   Set doc.startTime = dateTime
   doc.appointmentType = "4"
   doc.Alarms = "1"
   Set doc.startDate  = dateTime
   Set doc.endDate = dateTime
   Set doc.endTime = dateTime
   doc.save True , True
   doc.putInFolder "($Alarms)"
You can also figure out the ToDo code yourself.  All I did for meetings was to create a sample meeting in Notes, export the field list (you can see this in the second tab of document properties, or in a Structured Text export -- just do either one from the view).

I then set up fields for each one, only changing the SUBJECT field and all TIMEDATE fields.

If you want, I can do the same here, but don't you want the challenge yourself?!
Avatar of colishau

ASKER

Thanks for your response qwaltee,

I'm closer to a solution but I'm still having difficulties with your code.
At the moment I'm writing and testing on the Lotus 6 Demo and wonder if it's a difference between 4.x, 5 & 6.
The code isn't even creating the new NotesSession class successfully and I'm hitting a lot of dead ends.

The succesful code I have for sending mail from:
https://www.experts-exchange.com/questions/20643732/Emailing-from-VB.html

uses:
Set session = CreateObject( "Notes.NotesSession" ), handles the db & the doc fine.

but, in this case, causes trouble setting the dateTime field with
Set dateTime = s.createDateTime( position )

and doesn't give me the option of notifying recipients of the meeting, which is my objective.

Once again thanks, pressure and frustration don't mix well with me and I've upped the return to all the points I have available to try and make it worth your while.

Thanks,
Colin.


Take a look at the top two lines of teh code I gave you:

  Const Subject = "Test reminder subject"
  Const position = "some date or other"


You need to change them to appropriate values.  For example:


  Const Subject = "September staff meeting (Tuesday the ninth)"
  Const position = "9/9/2003 10:00 AM"

FYI, this code is compatible with both R5 and R6.

As to notifying recipients, I would have to research it to be sure, but I believe it is possible by merely doing the following:
Change FORM from Appointment to Meeting, and AppointmentType from 4 to 3
Add recipients by putting in ther full Notes names in teh SendTo field (more on that in a moment)
In additon to savingthe document, you then also send the document

Some information on Notes names:
Notes stores mail addresses in a "canonical" format similar to X.400.  So, if you are Colin Shau working for the Paris, France office of ExpertWorks, your name might be one of:
CN=Colin Shaul/OU=Paris/OU=France/O=ExpertWorks
CN=Colin Shaul/OU=France/O=ExpertWorks
CN=Colin Shaul/OU=Paris/O=ExpertWorks
CN=Colin Shaul/O=ExpertWorks

Will display respectively as:
Colin Shaul/Paris/France/ExpertWorks
Colin Shaul/France/ExpertWorks
Colin Shaul/Paris/ExpertWorks
Colin Shaul/ExpertWorks


You need the full canonical format.

Further, if you place more than one name in the SendTo fild, you must assign it via an array.  So, let's say you wanted to send the invitation to you and me. This might be your code:

 Const Subject = "September staff meeting (Tuesday the ninth)"
 Const position = "9/9/2003 10:00 AM"

  Dim invitees(1) As String
  invitees(0) = "CN=Colin Shaul/OU=Paris/OU=France/O=ExpertWorks"
  invitees(1) = "CN=Dovid Gross/O=DomBus"

  Dim s As New notesSession
  s.initialize
  Dim db As notesDatabase
  Set db = s.currentDatabase
  Dim doc As notesDocument
  Set doc = db.createDocument
  DOC.FORM = "Appointment" 'THIS IS THE NEW LINE
  Dim dateTime As NotesDateTime
  Set dateTime = s.createDateTime( position )
  doc.~$Alarm = 1
  doc.~$AlarmOffset = 0
  Print "Setting reminder/alarm - " dateTime.lslocalTime " - " Subject
  Set doc.startDateTime = dateTime
  Set doc.endDateTime = dateTime
  Set doc.calendarDateTime = dateTime
  doc.Subject = Subject
  Set doc.startTime = dateTime
  doc.appointmentType = "3"
  doc.Alarms = "1"
  Set doc.startDate  = dateTime
  Set doc.endDate = dateTime
  Set doc.endTime = dateTime
  doc.SendTo = invitees
  doc.save True , True
  doc.Send False
  doc.putInFolder "($Alarms)"
ASKER CERTIFIED SOLUTION
Avatar of qwaletee
qwaletee

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
I'm really grateful for all your help qwaletee.

I have enough to keep me going.

Take Care,
Colin.

P.S. If you know of any further resources , books or web, on this topic for full integration/ automation
            with VB & Notes I'd be very interested.
I'm afraid there aren't really any.  Some of the general Notes dev books touch on VB, and the Notes deigner help has an index entry for COM.  That's about it.
Ok, this is what I got and it works fine.
The only problem is inviting people to a meeting.

Could anyone tell me what field value do I need to replace in the DOC.REPLACEITEMVALUE to send invitations?
I presume it works from an array.
Thanks in advance,
Colin.

-----------CODE-------------------------
Dim session As Object
Dim db As Object 'notesDatabase
Dim doc As Object 'notesDocument
Dim startDateTime As Object
Dim endDateTime As Object
Dim DbLocation As String

Set session = CreateObject("Notes.NotesSession")   'notesSession
'get the name of the mailfile of the current user
DbLocation = session.GETENVIRONMENTSTRING("MailFile", True)
'Get the notesdatabase for the mail.
Set db = session.GETDATABASE("", DbLocation)
Set doc = db.CREATEDOCUMENT

Set startDateTime = session.CREATEDATETIME(txtAppStartDate.Text & " " & txtAppStartTime.Text)
Set endDateTime = session.CREATEDATETIME(txtAppStartDate.Text & " " & txtAppEndTime.Text)

'Set doc type
Call doc.REPLACEITEMVALUE("Form", "Appointment")
Call doc.REPLACEITEMVALUE("AppointmentType", "3")
                        '0: APPOINTMENT 1: ANNIVERSARY 2: ALL DAY 3 = MEETING 4 = REMINDER
'Set reminder alarm
Call doc.REPLACEITEMVALUE("$Alarm", 1)
Call doc.REPLACEITEMVALUE("$AlarmOffset", 0)
'Set Times and Dates
Call doc.REPLACEITEMVALUE("CalendarDateTime", startDateTime.LSLOCALTIME)
Call doc.REPLACEITEMVALUE("StartDateTime", startDateTime.LSLOCALTIME)
Call doc.REPLACEITEMVALUE("EndDateTime", endDateTime.LSLOCALTIME)
'Set Main Doc Attributes
Call doc.REPLACEITEMVALUE("Alarms", "1")
Call doc.REPLACEITEMVALUE("Chair", session.USERNAME)
Call doc.REPLACEITEMVALUE("Location", txtAppLocation.Text)
Call doc.REPLACEITEMVALUE("From", session.USERNAME)
Call doc.REPLACEITEMVALUE("Subject", txtAppSubject.Text)
Call doc.REPLACEITEMVALUE("SendTo", txtAppRecipient.Text)
Call doc.REPLACEITEMVALUE("Body", txtAppBody.Text)
Call doc.REPLACEITEMVALUE("ExcludefromView", "D")

doc.SAVE True, True
doc.SEND False
doc.PUTINFOLDER "($Alarms)"
On second thoughts, maybe that was a little vague.
I can sendto several recipients but they don't show up as invitees.
Play with the following foru fields I believe the first is the key one:

RequiredAttendees
AltRequiredNames
INetRequiredNames
Recipients


 - Qwaletee, with lights on!
In case anyone is searching for a similar solution, refer to this follow up -
https://www.experts-exchange.com/questions/20716077/Failure-to-Interpret-Received-Meeting.html