username = 'myname'  #if gw client is running, username must be same as logged in at client
commandline=''
password='mypass'		#just use '' if no password is set
import win32com.client
gwApp = win32com.client.Dispatch('NovellGroupWareSession')
acct1 = gwApp.Login(username,commandline,password)
print 'owner:',acct1.Owner.DisplayName
print 'IP address and port:', acct1.TCPIPAddress, acct1.TCPIPPort
calendar = acct1.Calendar
print 'calendar', calendar.Name
allAppts = calendar.FindMessages('APPOINTMENT')
print '# of appointments', allAppts.Count
nappts = min(allAppts.Count,10)
print 'first',nappts,'appointments'
for ix in range(1,nappts+1):
	appt = allAppts.Item(ix)
	if (not appt.Deleted):
		try: print ix, appt.StartDate, appt.EndDate, appt.Subject.PlainText
		except AttributeError: pass
print 'recent non-private appointments'
recentAppts = calendar.FindMessages('(APPOINTMENT) AND (NOT PRIVATE) AND (NOT HIDDEN) AND \
	(DUEEND_DATE> TODAY - 21) AND (START_DATE< TODAY + 1)')
for ix in range(1,recentAppts.Count+1):
	appt = recentAppts.Item(ix)
	if (not appt.Deleted):
		try: print ix, appt.StartDate, appt.EndDate, appt.Subject.PlainText
		except AttributeError: pass

