This is a simple class and test code to read the Contacts from Outlook using win32com, which is part of Mark Hammond's win32all package.
import win32com.client
DEBUG = 0
class MSOutlook:
def __init__(self):
self.outlookFound = 0
try:
self.oOutlookApp = \
win32com.client.gencache.EnsureDispatch("Outlook.Application")
self.outlookFound = 1
except:
print "MSOutlook: unable to load Outlook"
self.records = []
def loadContacts(self, keys=None):
if not self.outlookFound:
return
# this should use more try/except blocks or nested blocks
onMAPI = self.oOutlookApp.GetNamespace("MAPI")
ofContacts = \
onMAPI.GetDefaultFolder(win32com.client.constants.olFolderContacts)
if DEBUG:
print "number of contacts:", len(ofContacts.Items)
for oc in range(len(ofContacts.Items)):
contact = ofContacts.Items.Item(oc + 1)
if contact.Class == win32com.client.constants.olContact:
if keys is None:
# if we were't give a set of keys to use
# then build up a list of keys that we will be
# able to process
# I didn't include fields of type time, though
# those could probably be interpreted
keys = []
for key in contact._prop_map_get_:
if isinstance(getattr(contact, key), (int, str, unicode)):
keys.append(key)
if DEBUG:
keys.sort()
print "Fields\n======================================"
for key in keys:
print key
record = {}
for key in keys:
record[key] = getattr(contact, key)
if DEBUG:
print oc, record['FullName']
self.records.append(record)
if __name__ == '__main__':
if DEBUG:
print "attempting to load Outlook"
oOutlook = MSOutlook()
# delayed check for Outlook on win32 box
if not oOutlook.outlookFound:
print "Outlook not found"
sys.exit(1)
fields = ['FullName',
'CompanyName',
'MailingAddressStreet',
'MailingAddressCity',
'MailingAddressState',
'MailingAddressPostalCode',
'HomeTelephoneNumber',
'BusinessTelephoneNumber',
'MobileTelephoneNumber',
'Email1Address',
'Body'
]
if DEBUG:
import time
print "loading records..."
startTime = time.time()
# you can either get all of the data fields
# or just a specific set of fields which is much faster
#oOutlook.loadContacts()
oOutlook.loadContacts(fields)
if DEBUG:
print "loading took %f seconds" % (time.time() - startTime)
print "Number of contacts: %d" % len(oOutlook.records)
print "Contact: %s" % oOutlook.records[0]['FullName']
print "Body:\n%s" % oOutlook.records[0]['Body']
실용적인 디지털 포렌식 기법과 법률 이슈 정리. Linux, UNIX, Python, 임베디드 장치 개발 등의 강좌 수록. Blockchain, FinTech, IoT 등 최신 IT 트렌드와 관련된 취미 자료를 수집하고, 보안 인식 문화 개선을 위한 정보보호 관련 자료와 일상생활 팁들을 소개.
Reentrancy Attack: 블록체인 스마트 컨트랙트의 치명적인 취약점
블록체인 기술이 전 세계적으로 주목받으면서 스마트 컨트랙트(Smart Contract)의 사용이 급격히 증가하고 있습니다. 하지만 그만큼 보안 취약점도 함께 늘어나고 있는데, 그 중에서도 Reentrancy Attack(재진입 공격)은 매우 치명적이고...
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVoSf9jG9Tqh37erdszSR5UGvD95I2vJveHGDirDHYPCrsSxwUohRLDKwhyphenhyphen_LA7nEpIw3DveMT_zmqACnBmnebKTSS9KMRlL3hP3n_C6woK2V_brUXsQtxAOphBXtwyHtqSGIcJV21mGKZhU0KBeH-Rkvth6oJsRhyLtd2oMRV2BCfZ8luCXSTlXY6veK-/w320-h320/Reentrancy%20Attack%20%EB%B8%94%EB%A1%9D%EC%B2%B4%EC%9D%B8%20%EC%8A%A4%EB%A7%88%ED%8A%B8%20%EA%B3%84%EC%95%BD%EC%9D%98%20%EC%B9%98%EB%AA%85%EC%A0%81%20%EC%B7%A8%EC%95%BD%EC%A0%90.webp)
-
뉴스출처 : http://news.naver.com/main/read.nhn?mode=LSD&mid=sec&oid=023&aid=0002991158&sid1=001 내 배우자가 바람을 피우는 것이 확실할까. 심증...
-
PHPSCHOOL ( http://www.phpschool.com ) 국내 1위의 PHP 개발자 커뮤니티 사이트이다. PHP Builder ( http://www.phpbuilder.com ) PHP 최고 사이트라고 해도 과언이 아니며, 새로운 P...