473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Palm Desktop Syncs with Outlook

Here is a python script to synchronize Palm Desktop Datebook files with Outlook's Calendar

I'm releasing it under the Python license as version 0.1.
--------------------------------------------------------------------------------
''' palm2Outlook.py

Author: Jeff Mikels
Version: 0.1
License: Python
Purpose: Synchronize (only one way right now) Palm Desktop with MS Outlook
Usage: just run it, and then select the Calendar Folder to import Palm Desktop items into.
Warning: no duplicates are created. The Palm Desktop information writes over any Outlook items with the same text

Dependencies: palmFile.py, pythonWin
'''

import palmFile, win32com.client

def createAppointment(a,targetFolder):
return saveAppointment(a,targetFolder.Items.Add( 1 )) #olAppointmentItem = 1

def changeAppointment(a,appt):
targetFolder = appt.Parent
appt.Delete()
return createAppointment(a,targetFolder)

def saveAppointment(a,appt):
''' from palmFile
calendarEntryFields = (
"recordID",
"status",
"position",
"startTime",
"endTime",
"text",
"duration",
"note",
"untimed",
"private",
"category",
"alarmSet",
"alarmAdvUnits",
"alarmAdvType",
"repeatEvent"
)
'''
try:
if a['untimed']:
appt.AllDayEvent = 1

appt.Start = makeTime(a['startTime'])
appt.End = makeTime(a['endTime'])
appt.Subject = a['text']
appt.Body = a['note']

if a['alarmSet']:
if a['alarmAdvType'] == 0:
appt.ReminderMinutesBeforeStart = a['alarmAdvUnits']
elif a['alarmAdvType'] == 1: #hours
appt.ReminderMinutesBeforeStart = a['alarmAdvUnits'] * 60
else: #a['alarmAdvType'] = 2: #days
appt.ReminderMinutesBeforeStart = a['alarmAdvUnits'] * 60 * 24
else:
appt.ReminderSet = 0

if a['repeatEvent']['repeatEventFlag']:
repeatDetails = appt.GetRecurrencePattern()
if a['repeatEvent']['brand'] == 1: #daily
repeatDetails.RecurrenceType = 0 #olRecursDaily = 0

elif a['repeatEvent']['brand'] == 2: #weekly
repeatDetails.RecurrenceType = 1 #olRecursWeekly = 1
repeatDetails.DayOfWeekMask = ord(a['repeatEvent']['brandDaysMask'])

elif a['repeatEvent']['brand'] == 3: #monthly by day
repeatDetails.RecurrenceType = 3 #olRecursMonthlyNth = 3
repeatDetails.Instance = a['repeatEvent']['brandWeekIndex'] + 1 #Palm uses 0 for first week, but Outlook uses 1
#For Day of Week, Palm only uses one possible day
#and not a whole mask like Outlook. This field has Monday = 0 and Sunday = 6
#Outlook is looking for Sunday = 2**0, Monday = 2**1, Tues = 2**2 etc.
repeatDetails.DayOfWeekMask = 2**((a['repeatEvent']['brandDayIndex']+1) % 7)

elif a['repeatEvent']['brand'] == 4: #monthly by date
repeatDetails.RecurrenceType = 2 #olRecursMonthly = 2
repeatDetails.DayOfMonth = a['repeatEvent']['brandDayNumber']

elif a['repeatEvent']['brand'] == 5: #yearly
repeatDetails.RecurrenceType = 5 #olRecursYearly = 5
repeatDetails.MonthOfYear = a['repeatEvent']['brandMonthIndex'] + 1 #Palm stores this from 0-11
repeatDetails.DayOfMonth = a['repeatEvent']['brandDayNumber']

repeatDetails.PatternStartDate = makeDate(a['startTime'])
repeatDetails.Interval = a['repeatEvent']['interval']
if a['repeatEvent']['endDate'] != 1956545999:
repeatDetails.PatternEndDate = makeDate(a['repeatEvent']['endDate'])

appt.Save()
return appt
except:
import pprint
print '\nSAVE APPOINTMENT ERROR:\n\tsaveAppointment encountered an error while saving this item.\n'
pprint.pprint(a)
print '\n'
return None


def findAppt(a,folderToSearch):
try:
return folderToSearch.Items.Find('[Subject] = "' + a['text'] + '"')
except:
import pprint
print '\nFIND APPOINTMENT ERROR:\n\tfindAppt encountered an error looking for this event\n'
pprint.pprint(a)
print '\n'
return None

def makeDate(timeval):
import time
retVal = time.localtime(timeval)
return str(retVal[1]) + '/' + str(retVal[2]) + '/' + str(retVal[0]) # m/d/yyyy

def makeTime(timeval):
import time
retVal = time.strftime("%m/%d/%Y %I:%M %p", time.localtime(timeval))
return retVal

def parseOlTime(timestring):
import time
retVal = time.mktime(time.strptime(timestring,'%m/%d/%y %H:%M:%S'))
return retVal
palmData = 'c:\\Program Files\\Palm\\MikelsJ\\datebook\\datebook.dat'
fileStruct = palmFile.readPalmFile(palmData)
events = fileStruct[0]['datebookList']
#events = palmFile.getUpcomingEvents(fileStruct,7)
ol = win32com.client.Dispatch("Outlook.Application")
olNS = ol.GetNamespace("MAPI")
#olFolders = olNS.Folders()
calFolder = olNS.PickFolder()
#calFolder = olNS.Folders('Personal Folders').Folders('Calendar-Test')

for event in events:
appointment = findAppt(event,calFolder)
if not appointment:
appointment = createAppointment(event,calFolder)
#appointment.Display()
else:
pass
#appointment = changeAppointment(event,appointment)
#appointment.Display()
'''
DEFINING CONSTANTS
with win32com we can read the constants directly from Outlook's Object model at runtime

from win32com.client import gencache
gencache.EnsureModule('{00062FFF-0000-0000-C000-000000000046}', 0, 9, 0)

or

specify the constants directly
olAppointmentItem = 1

or run C:\Python23\Lib\site-packages\win32com\client\makepy.py and select Microsoft Outlook
this step parses all the constants and win32com keeps track of them
I've done this, so I can just use the constants (theoretically)
'''


--------------------------------------------------------------------------------

Jul 18 '05 #1
0 1718

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nick | last post by:
I use right now Borland Delphi and VB 6. But soon going to VB.net does anyone know of any components and or tools to build apps for the Palm OS Thanks Nick Smith Beaverton, or
1
by: Frank Taylor | last post by:
I am writing a simple viewer for a Palm Pilot database to run on my desktop machine. I have written a simple parser for PDB files, but it is not complete (does not deal with categories). Has anyone...
2
by: Paul Gross | last post by:
Does anyone know of a python module or script which can read the Palm Address Book Archives? Using Palm Desktop, I can export my addresses to a .aba file, but I can't find any code to use this...
4
by: djanvk | last post by:
QUick question: Is it possible to create a palm os program to use on a PDA with python? THanks
2
by: ChronoFish | last post by:
I know this topic comes up every so often - so I thought I would annoy everyone and ask again..... I am looking for a way to write PHP apps on a Palm based computer. Why? Because I like PHP,...
7
by: Joe Wasik | last post by:
Hello, Currently I used Biomobility's DataOnTheRun for the Pocket PC. It's a little slow, but it does exactly what I need -- and it does it well. Unfortunately, now I need to have the same...
0
by: Mabden | last post by:
Palm C people, I have had a Palm device foist upon me, so I wrote a nice game for it, but I don't know what newsgroup to use to find out info about straight C programming on the Palm. There seem...
3
by: dylpkls91 | last post by:
I am writing a program that uses the Palm handheld as a sort of input device. However, the code that communicates with it thru the serial port locks the port up, so if the user initiates a HotSync...
2
by: Kevin | last post by:
I will soon be purchasing my first PDA for use on my job and I would like to (in time) create a sync between the Access db that I use on my desktop and something for the pda. It would primarily be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.