def SetProperties(msg, propDict):
 newProps = []
 for (key, val) in propDict.iteritems():
  if (type(key) in [str, unicode]):
   newProps.append((mapi.PS_PUBLIC_STRINGS, key))
 if newProps:
  newIds = msg.GetIDsFromNames(newProps, mapi.MAPI_CREATE)
 newIdNo = 0
 newProps = []
 for (key, val) in propDict.iteritems():
  if (type(key) in [str, unicode]):
   type_val = type(val)
   if (type_val in [str, unicode]):
    tagType = mapitags.PT_UNICODE
   elif (type_val == IntType):
    tagType = mapitags.PT_I4
   elif (type_val == TimeType):
    tagType = mapitags.PT_SYSTIME
   else:
    raise ValueError(('The type of object %s(%s) can not be written' % (repr(val), type_val)))
   key = mapitags.PROP_TAG(tagType, mapitags.PROP_ID(newIds[newIdNo]))
   newIdNo = (newIdNo + 1)
  newProps.append((key, val))
 msg.SetProps(newProps)

def SetProperties ( msg , propDict ) : newProps = [ ] for ( key , val ) in propDict . iteritems ( ) : if ( type ( key ) in [ str , unicode ] ) : newProps . append ( ( mapi . PS_PUBLIC_STRINGS , key ) ) if newProps : newIds = msg . GetIDsFromNames ( newProps , mapi . MAPI_CREATE ) newIdNo = 0 newProps = [ ] for ( key , val ) in propDict . iteritems ( ) : if ( type ( key ) in [ str , unicode ] ) : type_val = type ( val ) if ( type_val in [ str , unicode ] ) : tagType = mapitags . PT_UNICODE elif ( type_val == IntType ) : tagType = mapitags . PT_I4 elif ( type_val == TimeType ) : tagType = mapitags . PT_SYSTIME else : raise ValueError ( ( 'The type of object %s(%s) can not be written' % ( repr ( val ) , type_val ) ) ) key = mapitags . PROP_TAG ( tagType , mapitags . PROP_ID ( newIds [ newIdNo ] ) ) newIdNo = ( newIdNo + 1 ) newProps . append ( ( key , val ) ) msg . SetProps ( newProps )
given a python dictionary .