[python-win32] get embedded images from outlook
Antony Joseph
antonyjoseph89 at gmail.com
Sat Jan 5 08:04:58 CET 2008
Hi ,
This code can read the content of mails body , html and headers from
outlook.
in case , it there's an embedded image,
Its not getting the image,
My code.......
def GetPropFromStream(mapi_object,prop_id):
try:
stream = mapi_object.OpenProperty(prop_id,
pythoncom.IID_IStream,
0, 0)
chunks = []
while 1:
chunk = stream.Read(4096)
if not chunk:
break
chunks.append(chunk)
return "".join(chunks)
except pythoncom.com_error, d:
print "Error getting property", mapiutil.GetPropTagName(prop_id),
\
"from stream:", d
return ""
def GetPotentiallyLargeStringProp(mapi_object,prop_id,row):
got_tag,got_val = row
if PROP_TYPE(got_tag) == PT_ERROR:
ret = ""
if got_val == mapi.MAPI_E_NOT_FOUND:
pass # No property for this message.
elif got_val == mapi.MAPI_E_NOT_ENOUGH_MEMORY:
# Too big for simple properties - get via a stream
ret =GetPropFromStream(mapi_object,prop_id)
else:
tag_name = mapiutil.GetPropTagName(prop_id)
err_string = mapiutil.GetScodeString(got_val)
print "Warning - failed to get property %s: %s" %
(tag_name,err_string)
else:
ret = got_val
prop_ids = (PR_BODY_A,MYPR_BODY_HTML_A,PR_TRANSPORT_MESSAGE_HEADERS_A)
hr,data=obj.GetProps(prop_ids,0)
body = GetPotentiallyLargeStringProp(obj,prop_ids[0],data[0])
html = GetPotentiallyLargeStringProp(obj,prop_ids[1],data[1])
headers =GetPotentiallyLargeStringProp(obj,prop_ids[2],data[2])
can anybody tell me ,
how can i get the images?
Antony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20080105/b1449114/attachment-0001.htm
More information about the python-win32
mailing list