Re: [python-win32] OT: Syncing routes ...

2010-03-22 Thread Tim Golden

On 19/03/2010 19:56, Clinton Lee Taylor wrote:

Greetings ...

I'm still very new to Python, so please excuss my request ... I have
written some very basic Python utils and slowly get my head around
Python and com objects in Windows ...

  I was hoping that I might be able to bug the list for any pointers on
syncing routes, that I could use to sync records from one DB to
another ... Basically looking to sync Outlook Contacts into and from a
MySQL DB.  Later, would like to extend this to include Windows Address
Book, Thunderbird Contacts and maybe any other DateBase.


Well I'm no expert in this area, but since I've not seen any other
replies I'll have a stab. Your question is quite wide-ranging,
taking in several major software packages, all of which have
quite different access methods. You say you're new to Python
(and presumably to Windows development, if you're coming to terms
with COM). Do you have any other development experience?

Outlook contacts can be read via the so-called CDO libraries.
This is the definitive starting point:

  http://msdn.microsoft.com/en-us/library/ms988614%28EXCHG.65%29.aspx

and there's some good resources here:

  http://www.cdolive.com/default.htm

For the most part, CDO is easy enough to translate into Python.
I have some examples here (altho' not contact-related):

  http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html
  
http://timgolden.me.uk/python/win32_how_do_i/replace-outlook-attachments-with-links.html
  http://timgolden.me.uk/python/win32_how_do_i/create-an-mhtml-archive.html

and once you've got hold of the terms you need, you can easily
Google around for more.

Then you have the database side. You mention MySQL but you might be better off
using sqlite, an interface to which is included with Python in recent versions.
This is, of course, unless you have a truly huge list of contacts, or an
existing investment in MySQL.

  http://sqlite.org/
  http://docs.python.org/library/sqlite3.html

There certainly are Python bindings to MySQL altho' I'm not a user myself
so I'm not sure which ones favoured at the moment. Worth asking on the
main Python lists.

Hopefully that's enough to get you started. Feel free to post back with
more questions or info. If your questions aren't win32 specific you
might get more answers on the main Python mailing list:

  http://mail.python.org/mailman/listinfo/python-list

TJG
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Finding the physical USBSTOR disk size

2010-03-22 Thread Tim Golden

On 19/03/2010 10:30, Chris Jesse wrote:

I am trying to use WMI in order to get information about drives so
The problem that we are having is that we can't seem to get an accurate
size for the disks.



I know that in the past we were able to do so, using the Win32_Diskpartition
Size property but have recently found that this is no longer the case as it is
inaccurate. We believe this is because we may not have tested it with a FAT
formatted media before.


I'm not going to be much help here, I'm afraid, except to suggest that
the likely API for this is going to be one of the DeviceIOControl
functions:

  http://msdn.microsoft.com/en-us/library/aa363216%28VS.85%29.aspx

  http://timgolden.me.uk/pywin32-docs/win32file__DeviceIoControl_meth.html

In principle, the parents of the Win32_LogicalDisk clsas (CIM_LogicalDisk,
CIM_StorageExtent) should offer access to the lower-level data which
makes up the Size attributes. But it doesn't seem to be implemented that
way; they simply return None.

TJG
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] MAPI with win32com

2010-03-22 Thread Werner F. Bruhin
I am trying to use MAPI to send an email using win32com, but I get the 
following exception.


from win32com.client import Dispatch
s = Dispatch("Mapi.Session")
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\site-packages\win32com\client\__init__.py", 
line 95, in Dispatch
dispatch, userName = 
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line 
98, in _GetGoodDispatchAndUserName

return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line 
78, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, 
pythoncom.IID_IDispatch)

com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)

I first tried this having Thunderbird as my MAPI client, then installed 
Windows Live Email (I want to test MAPI with one of the "newer" MS Mail 
clients) and defined it as the MAPI client (Default Programs - MAPI), 
still same result.


Any hints on what I am doing wrong here would be very much welcomed.

I am on Windows 7, Python 2.5.4, py2in32 build 210.

Werner

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread Werner F. Bruhin

On 22/03/2010 12:06, Werner F. Bruhin wrote:

I am trying to use MAPI to send an email using win32com, but I get the
following exception.

from win32com.client import Dispatch
s = Dispatch("Mapi.Session")
Traceback (most recent call last):
File "", line 1, in 
File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line
95, in Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
98, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
78, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)

I first tried this having Thunderbird as my MAPI client, then installed
Windows Live Email (I want to test MAPI with one of the "newer" MS Mail
clients) and defined it as the MAPI client (Default Programs - MAPI),
still same result.

Any hints on what I am doing wrong here would be very much welcomed.

I am on Windows 7, Python 2.5.4, py2in32 build 210.

Werner
Just came accross Tim Golden's site 
(http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html) and 
tried this:


session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")

But I do get the same exception.

Werner


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread Tim Golden

On 22/03/2010 11:22, Werner F. Bruhin wrote:

On 22/03/2010 12:06, Werner F. Bruhin wrote:

I am trying to use MAPI to send an email using win32com, but I get the
following exception.

from win32com.client import Dispatch
s = Dispatch("Mapi.Session")
Traceback (most recent call last):
File "", line 1, in
File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line
95, in Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
98, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
78, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)

I first tried this having Thunderbird as my MAPI client, then installed
Windows Live Email (I want to test MAPI with one of the "newer" MS Mail
clients) and defined it as the MAPI client (Default Programs - MAPI),
still same result.

Any hints on what I am doing wrong here would be very much welcomed.

I am on Windows 7, Python 2.5.4, py2in32 build 210.

Werner

Just came accross Tim Golden's site
(http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html) and
tried this:

session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")

But I do get the same exception.


Have a look at:

  http://kb.mozillazine.org/MAPI_Support

which explains that TB (like OE) only supports "Simple MAPI". There's
a whole confusion of terminology around this area, but I'm afraid that
the bottom line is: the only client which really supports CDO, ie MAPI.Session
is the full Outlook client. It's just about possible to use CDO without
installing Outlook (by installing some standalone package whose name
escapes me) but that still only gives you access to Exchange, not to
whatever interface TB exposes.

TJG
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Finding the physical USBSTOR disk size

2010-03-22 Thread Chris Jesse
Thanks Tim, 

Shame about the None returns; I keep on bumping up against these! 

I'm currently going for the over-read exception - a bit like over-kill, we read 
beyond the size reported in the smallest block size chunks (512 bytes) until an 
exception is raised. It does mean we will get 101% read progress reports and a 
slight delay at the end of our progress bar, but much like progress reported by 
Microsoft Minutes, it's an inaccuracy we can live with. 

Thanks for help, Chris. 

- Original Message - 
From: "Tim Golden"  
Cc: "Python win32 User List"  
Sent: Monday, 22 March, 2010 10:09:49 GMT +00:00 GMT Britain, Ireland, Portugal 
Subject: Re: [python-win32] Finding the physical USBSTOR disk size 

On 19/03/2010 10:30, Chris Jesse wrote: 
> I am trying to use WMI in order to get information about drives so 
>The problem that we are having is that we can't seem to get an accurate 
>size for the disks. 

> I know that in the past we were able to do so, using the Win32_Diskpartition 
> Size property but have recently found that this is no longer the case as it 
> is 
> inaccurate. We believe this is because we may not have tested it with a FAT 
> formatted media before. 

I'm not going to be much help here, I'm afraid, except to suggest that 
the likely API for this is going to be one of the DeviceIOControl 
functions: 

http://msdn.microsoft.com/en-us/library/aa363216%28VS.85%29.aspx 

http://timgolden.me.uk/pywin32-docs/win32file__DeviceIoControl_meth.html 

In principle, the parents of the Win32_LogicalDisk clsas (CIM_LogicalDisk, 
CIM_StorageExtent) should offer access to the lower-level data which 
makes up the Size attributes. But it doesn't seem to be implemented that 
way; they simply return None. 

TJG 
___ 
python-win32 mailing list 
python-win32@python.org 
http://mail.python.org/mailman/listinfo/python-win32 
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Finding the physical USBSTOR disk size

2010-03-22 Thread Tim Golden

On 22/03/2010 11:41, Chris Jesse wrote:

Shame about the None returns; I keep on bumping up against these!




I'm currently going for the over-read exception - a bit like over-kill,
we read beyond the size reported in the smallest block size chunks (512 bytes)
until an exception is raised. It does mean we will get 101% read progress 
reports
and a slight delay at the end of our progress bar, but much like progress 
reported
by Microsoft Minutes, it's an inaccuracy we can live with.


Heh. http://xkcd.com/612/   :)

Glad you've got something of a solution anyway

TJG
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread Werner F. Bruhin

Tim,

Thanks for the quick response.

On 22/03/2010 12:26, Tim Golden wrote:

On 22/03/2010 11:22, Werner F. Bruhin wrote:

On 22/03/2010 12:06, Werner F. Bruhin wrote:

I am trying to use MAPI to send an email using win32com, but I get the
following exception.

from win32com.client import Dispatch
s = Dispatch("Mapi.Session")
Traceback (most recent call last):
File "", line 1, in
File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line
95, in Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
98, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
78, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)

I first tried this having Thunderbird as my MAPI client, then installed
Windows Live Email (I want to test MAPI with one of the "newer" MS Mail
clients) and defined it as the MAPI client (Default Programs - MAPI),
still same result.

Any hints on what I am doing wrong here would be very much welcomed.

I am on Windows 7, Python 2.5.4, py2in32 build 210.

Werner

Just came accross Tim Golden's site
(http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html)
and
tried this:

session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")

But I do get the same exception.


Have a look at:

http://kb.mozillazine.org/MAPI_Support

which explains that TB (like OE) only supports "Simple MAPI". There's
a whole confusion of terminology around this area, but I'm afraid that
the bottom line is: the only client which really supports CDO, ie
MAPI.Session
is the full Outlook client. It's just about possible to use CDO without
installing Outlook (by installing some standalone package whose name
escapes me)

I found this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en

At least I get past the above error, will see how far I get with this.
 but that still only gives you access to Exchange, not to

whatever interface TB exposes.
Clients and me using TB are fine, I support that with the simplemapi.py 
(http://www.johnnypops.demon.co.uk/python/simplemapi.py) and it works 
fine, but clients who use Outlook (e.g. Office 11) get a MAPI error 2 
(failure).


TJG


I don't want to use Outlook, but I like to provide an additional way of 
sending problem reports from within my application to me (MAPI, 
smtplib), so hoped that I could use extended MAPI stuff.


I guess I just have to get my hands onto an Outlook to be able to test 
this stuff.



Werner

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread Tim Golden

[Tim Golden]
the only client which really supports CDO, ie

MAPI.Session
is the full Outlook client. It's just about possible to use CDO without
installing Outlook (by installing some standalone package whose name
escapes me)


[Werner Bruhin]

I found this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en


Yep. Think that's the one.


At least I get past the above error, will see how far I get with this.
   but that still only gives you access to Exchange, not to

whatever interface TB exposes.


That's really the problem. AFAICT, CDO is *basically* an interface to
Exchange via Outlook. You can just about get away without the Outlook
bit by installing the download you mention (which presumably includes
the necessary bits of Outlook without the front-end). But I don't
honestly think you can get away without Exchange. I suspect the idea
is that you should be able to. But I'm not aware that anyone's
implemented it to the extent that you could. Happy to be wrong.


I don't want to use Outlook, but I like to provide an additional way of
sending problem reports from within my application to me (MAPI,
smtplib), so hoped that I could use extended MAPI stuff.


Hmmm. Good luck and keep us posted. For my understanding, is there
some reason you can't simply send via SMTP directly? Do you need
the intervening client?

TJG
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread python
Werner,

I'm not sure I understand the benefit of being locked into the
proprietary and awkward MAPI protocol?

Why can't you use industry standard SMTP to send your messages? Simpler
and more portable.

Malcolm


- Original message -
From: "Werner F. Bruhin" 
To: python-win32@python.org
Date: Mon, 22 Mar 2010 13:40:52 +0100
Subject: Re: [python-win32] MAPI with win32com

Tim,

Thanks for the quick response.

On 22/03/2010 12:26, Tim Golden wrote:
> On 22/03/2010 11:22, Werner F. Bruhin wrote:
>> On 22/03/2010 12:06, Werner F. Bruhin wrote:
>>> I am trying to use MAPI to send an email using win32com, but I get the
>>> following exception.
>>>
>>> from win32com.client import Dispatch
>>> s = Dispatch("Mapi.Session")
>>> Traceback (most recent call last):
>>> File "", line 1, in
>>> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line
>>> 95, in Dispatch
>>> dispatch, userName =
>>> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
>>> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
>>> 98, in _GetGoodDispatchAndUserName
>>> return (_GetGoodDispatch(IDispatch, clsctx), userName)
>>> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
>>> 78, in _GetGoodDispatch
>>> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
>>> pythoncom.IID_IDispatch)
>>> com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)
>>>
>>> I first tried this having Thunderbird as my MAPI client, then installed
>>> Windows Live Email (I want to test MAPI with one of the "newer" MS Mail
>>> clients) and defined it as the MAPI client (Default Programs - MAPI),
>>> still same result.
>>>
>>> Any hints on what I am doing wrong here would be very much welcomed.
>>>
>>> I am on Windows 7, Python 2.5.4, py2in32 build 210.
>>>
>>> Werner
>> Just came accross Tim Golden's site
>> (http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html)
>> and
>> tried this:
>>
>> session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")
>>
>> But I do get the same exception.
>
> Have a look at:
>
> http://kb.mozillazine.org/MAPI_Support
>
> which explains that TB (like OE) only supports "Simple MAPI". There's
> a whole confusion of terminology around this area, but I'm afraid that
> the bottom line is: the only client which really supports CDO, ie
> MAPI.Session
> is the full Outlook client. It's just about possible to use CDO without
> installing Outlook (by installing some standalone package whose name
> escapes me)
I found this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en

At least I get past the above error, will see how far I get with this.
  but that still only gives you access to Exchange, not to
> whatever interface TB exposes.
Clients and me using TB are fine, I support that with the simplemapi.py 
(http://www.johnnypops.demon.co.uk/python/simplemapi.py) and it works 
fine, but clients who use Outlook (e.g. Office 11) get a MAPI error 2 
(failure).
>
> TJG

I don't want to use Outlook, but I like to provide an additional way of 
sending problem reports from within my application to me (MAPI, 
smtplib), so hoped that I could use extended MAPI stuff.

I guess I just have to get my hands onto an Outlook to be able to test 
this stuff.


Werner

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread King Simon-NFHD78
> -Original Message-
> From: python-win32-bounces+simon.king=motorola@python.org 
> [mailto:python-win32-bounces+simon.king=motorola@python.or
> g] On Behalf Of pyt...@bdurham.com
> Sent: 22 March 2010 13:11
> To: Werner F. Bruhin; zz Python Win32 Newsgroup
> Subject: Re: [python-win32] MAPI with win32com
> 
> Werner,
> 
> I'm not sure I understand the benefit of being locked into the
> proprietary and awkward MAPI protocol?
> 
> Why can't you use industry standard SMTP to send your 
> messages? Simpler
> and more portable.
> 
> Malcolm
> 

I can't speak for Werner, but I recently had a request from a user of my
application for an 'email this project' button on the toolbar, which
would create an email message, attach the current project to it, and
then allow the user to edit the message body itself.

If I use SMTP, I need the user to enter all the SMTP configuration
details (host, username, password, TLS etc). The email won't end up in
his "Sent Items" folder. He probably won't be able to use Rich Text or
HTML in the email (of course, you could argue that that is a good thing
:-)

Unfortunately, popping up an Outlook window with the file already
attached is just a better user experience.

I would love it if there were a way to do this that worked in the user's
preferred mail client. If it were cross-platform, that would be even
better. At the moment I use 'mailto:' URLs with os.startfile on Windows,
and /usr/bin/open on the Mac. These work for opening an email with the
To, Subject and message body already filled in, but I don't think
there's any way I can attach a file like that. It also doesn't work if
the message body is too long, presumably because of command-line length
restrictions :-(

Simon
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread Tim Golden

On 22/03/2010 13:28, King Simon-NFHD78 wrote:

I can't speak for Werner, but I recently had a request from a user of my
application for an 'email this project' button on the toolbar, which
would create an email message, attach the current project to it, and
then allow the user to edit the message body itself.


That would be the kind of scenario I had envisaged. Of course, you
could run up a suitable window yourself before handing off to SMTP etc.
but then you're presenting your user with a different interface
than the one he/she is used to and/or you have to re-implement all
the different buttons (address book, spell check etc.) which is
doubtless more trouble than it's worth.


Unfortunately, popping up an Outlook window with the file already
attached is just a better user experience.


Agreed. (If they normally use Outlook :) )


I would love it if there were a way to do this that worked in the user's
preferred mail client.


There just isn't, and there isn't really the incentive, I believe
from any of the email client providers to do that. As you point out, you
can use a mailto: link with a certain amount of flexibility. You
could, I imagine [WARNING: unconsidered idea ahead] pre-drop the attachment
to dropbox or sendfile or one of these online services and then the
body of the email could just include the link to the online file.

TJG
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread Mike Driscoll

Hi Werner,



I found this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en 



At least I get past the above error, will see how far I get with this.
 but that still only gives you access to Exchange, not to

whatever interface TB exposes.
Clients and me using TB are fine, I support that with the 
simplemapi.py (http://www.johnnypops.demon.co.uk/python/simplemapi.py) 
and it works fine, but clients who use Outlook (e.g. Office 11) get a 
MAPI error 2 (failure).


TJG


I don't want to use Outlook, but I like to provide an additional way 
of sending problem reports from within my application to me (MAPI, 
smtplib), so hoped that I could use extended MAPI stuff.


I guess I just have to get my hands onto an Outlook to be able to test 
this stuff.



Werner




I found this recipe: http://code.activestate.com/recipes/149461-mapi-send/

Since we dropped Exchange in favor of Zimbra, I cannot test this 
solution, but maybe it will help you. By the way, is smtplib not working 
for you?


--
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread Werner F. Bruhin

Hi Malcolm,

On 22/03/2010 14:10, pyt...@bdurham.com wrote:

Werner,

I'm not sure I understand the benefit of being locked into the
proprietary and awkward MAPI protocol?

Why can't you use industry standard SMTP to send your messages? Simpler
and more portable.
I already offer the SMTP option, i.e. there are two buttons, one is 
using smtplib and the other uses MAPI.


As Simon pointed out some users don't like that a message is sent where 
they don't see what is being sent (they actually do in my case as I show 
the details of the error and on that dialog they click one of the two 
buttons).


Werner


Malcolm


- Original message -
From: "Werner F. Bruhin"
To: python-win32@python.org
Date: Mon, 22 Mar 2010 13:40:52 +0100
Subject: Re: [python-win32] MAPI with win32com

Tim,

Thanks for the quick response.

On 22/03/2010 12:26, Tim Golden wrote:

On 22/03/2010 11:22, Werner F. Bruhin wrote:

On 22/03/2010 12:06, Werner F. Bruhin wrote:

I am trying to use MAPI to send an email using win32com, but I get the
following exception.

from win32com.client import Dispatch
s = Dispatch("Mapi.Session")
Traceback (most recent call last):
File "", line 1, in
File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line
95, in Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
98, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
78, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)

I first tried this having Thunderbird as my MAPI client, then installed
Windows Live Email (I want to test MAPI with one of the "newer" MS Mail
clients) and defined it as the MAPI client (Default Programs - MAPI),
still same result.

Any hints on what I am doing wrong here would be very much welcomed.

I am on Windows 7, Python 2.5.4, py2in32 build 210.

Werner

Just came accross Tim Golden's site
(http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html)
and
tried this:

session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")

But I do get the same exception.


Have a look at:

http://kb.mozillazine.org/MAPI_Support

which explains that TB (like OE) only supports "Simple MAPI". There's
a whole confusion of terminology around this area, but I'm afraid that
the bottom line is: the only client which really supports CDO, ie
MAPI.Session
is the full Outlook client. It's just about possible to use CDO without
installing Outlook (by installing some standalone package whose name
escapes me)

I found this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en

At least I get past the above error, will see how far I get with this.
   but that still only gives you access to Exchange, not to

whatever interface TB exposes.

Clients and me using TB are fine, I support that with the simplemapi.py
(http://www.johnnypops.demon.co.uk/python/simplemapi.py) and it works
fine, but clients who use Outlook (e.g. Office 11) get a MAPI error 2
(failure).


TJG


I don't want to use Outlook, but I like to provide an additional way of
sending problem reports from within my application to me (MAPI,
smtplib), so hoped that I could use extended MAPI stuff.

I guess I just have to get my hands onto an Outlook to be able to test
this stuff.


Werner

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32



___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread Werner F. Bruhin

On 22/03/2010 13:58, Tim Golden wrote:

[Tim Golden]
the only client which really supports CDO, ie

MAPI.Session
is the full Outlook client. It's just about possible to use CDO without
installing Outlook (by installing some standalone package whose name
escapes me)


[Werner Bruhin]

I found this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en



Yep. Think that's the one.


At least I get past the above error, will see how far I get with this.
but that still only gives you access to Exchange, not to

whatever interface TB exposes.


That's really the problem. AFAICT, CDO is *basically* an interface to
Exchange via Outlook. You can just about get away without the Outlook
bit by installing the download you mention (which presumably includes
the necessary bits of Outlook without the front-end). But I don't
honestly think you can get away without Exchange. I suspect the idea
is that you should be able to. But I'm not aware that anyone's
implemented it to the extent that you could. Happy to be wrong.


I don't want to use Outlook, but I like to provide an additional way of
sending problem reports from within my application to me (MAPI,
smtplib), so hoped that I could use extended MAPI stuff.


Hmmm. Good luck and keep us posted.
The luck run out pretty quickly - get to the logon but then it seems to 
want an existing profile.  So, back on having to get myself a copy of 
outlook to be able to test this stuff:(.

 For my understanding, is there

some reason you can't simply send via SMTP directly? Do you need
the intervening client?
I do offer the SMTP option using smtplib which works great, but some 
clients don't know/like to fill in the configuration stuff needed and 
others really want to see in their email client of choice the email to 
go out and it also gives them the record/archive of what has been sent.


Werner

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread Werner F. Bruhin

On 22/03/2010 14:28, King Simon-NFHD78 wrote:

-Original Message-
From: python-win32-bounces+simon.king=motorola@python.org
[mailto:python-win32-bounces+simon.king=motorola@python.or
g] On Behalf Of pyt...@bdurham.com
Sent: 22 March 2010 13:11
To: Werner F. Bruhin; zz Python Win32 Newsgroup
Subject: Re: [python-win32] MAPI with win32com

Werner,

I'm not sure I understand the benefit of being locked into the
proprietary and awkward MAPI protocol?

Why can't you use industry standard SMTP to send your
messages? Simpler
and more portable.

Malcolm



I can't speak for Werner, but I recently had a request from a user of my
application for an 'email this project' button on the toolbar, which
would create an email message, attach the current project to it, and
then allow the user to edit the message body itself.

If I use SMTP, I need the user to enter all the SMTP configuration
details (host, username, password, TLS etc). The email won't end up in
his "Sent Items" folder. He probably won't be able to use Rich Text or
HTML in the email (of course, you could argue that that is a good thing
:-)

Unfortunately, popping up an Outlook window with the file already
attached is just a better user experience.

I would love it if there were a way to do this that worked in the user's
preferred mail client. If it were cross-platform, that would be even
better. At the moment I use 'mailto:' URLs with os.startfile on Windows,
and /usr/bin/open on the Mac. These work for opening an email with the
To, Subject and message body already filled in, but I don't think
there's any way I can attach a file like that. It also doesn't work if
the message body is too long, presumably because of command-line length
restrictions :-(
I used "mailto" in the past, but I need to attach log files, therefore I 
switched to using simplemapi.py which works fine except with the newer 
versions of Outlook (I know that Outlook included with Office 11 has a 
problem, not sure about others).


Werner

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread Werner F. Bruhin

Hi Mike,

On 22/03/2010 14:48, Mike Driscoll wrote:

Hi Werner,



I found this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en


At least I get past the above error, will see how far I get with this.
 but that still only gives you access to Exchange, not to

whatever interface TB exposes.

Clients and me using TB are fine, I support that with the
simplemapi.py (http://www.johnnypops.demon.co.uk/python/simplemapi.py)
and it works fine, but clients who use Outlook (e.g. Office 11) get a
MAPI error 2 (failure).


TJG


I don't want to use Outlook, but I like to provide an additional way
of sending problem reports from within my application to me (MAPI,
smtplib), so hoped that I could use extended MAPI stuff.

I guess I just have to get my hands onto an Outlook to be able to test
this stuff.


Werner




I found this recipe: http://code.activestate.com/recipes/149461-mapi-send/
That is basically the same thing as I tried, it needs more then the 
download I mentioned in the other post.


Since we dropped Exchange in favor of Zimbra, I cannot test this
solution, but maybe it will help you. By the way, is smtplib not working
for you?
smtplib is working great, but as mentioned before some users prefer 
using their email client (i.e. see what is going out, have an 
archive/copy of it ) and MAPI solution if it works (which it does 
with all kind of software (Thunderbird, older outlook version ) it 
requires no setup at all in my software.


Werner

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread niki

try this (simple mapi with ctypes):

http://aspn.activestate.com/ASPN/Mail/Message/ctypes-users/2095322

HTH
Niki
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] cde Outlook 2007 rules and python

2010-03-22 Thread nihil
Is really no one out there who could point me in the right direction?


On Wed, 3 Mar 2010 10:58:41 +0100
 wrote:

> I try to translate this vbs script to python.
> http://www.outlookcode.com/threads.aspx?forumid=2&messageid=29505
> The purpose of this script is to automatically create an rule in Outlook to 
> sort incoming messages.
> It is possible to do this in Outlook 2007 and the vbs file works. The SPAM 
> folder is writable so thats not the problem.
> 
> This code works but only creates an rule that forwards the messages to an 
> another mail address:
> 
> #!/bin/env python
> # -*- coding: UTF-8 -*-
> import codecs
> import tempfile
> import win32api
> import win32com.client
> import sys,os
> constants = win32com.client.constants
> application = win32com.client.Dispatch("Outlook.Application")
> rules = application.Session.DefaultStore.GetRules()
> _folder = application.Session.GetDefaultFolder(constants.olFolderInbox)
> _spamfolder = _folder.Folders["Spam"]
> _rule = rules.Create("SPAM",constants.olRuleReceive)
> _condition = _rule.Conditions.MessageHeader
> _condition.Text = ["X-Spam-Status: Yes"]
> _condition.Enabled = True
> _action = _rule.Actions.Forward
> _action.Recipients.Add("m...@mail.com")
> _action.Enabled = True
> _rule.Enabled = True
> rules.Save()
> 
> This is the code i need but it is not working:
> 
> #!/bin/env python
> # -*- coding: UTF-8 -*-
> import codecs
> import tempfile
> import win32api
> import win32com.client
> import sys,os
> 
> constants = win32com.client.constants
> application = win32com.client.Dispatch("Outlook.Application")
> rules = application.Session.DefaultStore.GetRules()
> _folder = application.Session.GetDefaultFolder(constants.olFolderInbox)
> _spamfolder = _folder.Folders["Spam"]
> _rule = rules.Create("SPAM",constants.olRuleReceive)
> _condition = _rule.Conditions.MessageHeader
> _condition.Text = ["X-Spam-Status: Yes"]
> _condition.Enabled = True
> _action = _rule.Actions.MoveToFolder
> _action.Folder = _spamfolder
> _spamfolder2 = _spamfolder
> print _spamfolder, _spamfolder2, _action.Folder
> _action.Enabled = True
> _rule.Enabled = True
> rules.Save()
> 
> The problem is that even after the assignment and in my print _action.Folder 
> contains None but
> _spamfolder and _spamfolder2 both contain an reference to the 
> Library.MAPIFolder. 
> Could anyone please enlighten me. Why is _action.Folder empty?
> It seems the vbs guys have the same problem but they use "Set 
> objActionMoveToFolder.Folder = objFolderJunk"
> instead of "objActionMoveToFolder.Folder = objFolderJunk" 
> 
> 
> 
> 
> 
> 
> ___
> python-win32 mailing list
> python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread python
Werner,

> I do offer the SMTP option using smtplib which works great, but some 
clients don't know/like to fill in the configuration stuff needed and 
others really want to see in their email client of choice the email to 
go out and it also gives them the record/archive of what has been sent.

We solved the configuration issues by posting to a PHP form that in turn
sends out our emails.

We solved the record/archive concern by bcc-ing the customer's email
with a copy of what was being sent.

Malcolm
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] I/O error

2010-03-22 Thread travel europe

Hello,

 

I am getting the following error "ValueError: I/O operation on closed file" 
when running a module to pull data from the Windows registry.

 

The code is as follows: 

 



import csv
from winsys import registry

 

key = r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
fields = ["DisplayName", "Comments", "InstallDate"] # add to as required

 

uninstall = registry.registry (key)
with open ("installed.txt", "wb") as f:
 writer = csv.writer (f)
 writer.writerow (fields)
for subkey in uninstall:
 info = dict (subkey.values ())
 writer.writerow ([info.get (field) for field in fields])


 



The error message is as follows:

Traceback (most recent call last):
  File "C:\Python26\tim.py", line 13, in 
writer.writerow ([info.get (field) for field in fields])
ValueError: I/O operation on closed file



 

Any ideas on how to rectify this problem? Thanks!
  
_
Hotmail is redefining busy with tools for the New Busy. Get more from your 
inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID27925::T:WLMTAGL:ON:WL:en-US:WM_HMP:032010_2___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] I/O error

2010-03-22 Thread Preston Landers
Your indentation is a bit hard to read in this format, but it looks like the
"for subkey in uninstall" block needs to be inside the "with open" block.
When the "with open" block exits, the file is no longer open.  Thus writing
to a closed file will fail.


On Mon, Mar 22, 2010 at 4:22 PM, travel europe wrote:

>  Hello,
>
> I am getting the following error "ValueError: I/O operation on closed file"
> when running a module to pull data from the Windows registry.
>
> The code is as follows:
>
> 
> import csv
> from winsys import registry
>
> key =
> r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
> fields = ["DisplayName", "Comments", "InstallDate"] # add to as required
>
> uninstall = registry.registry (key)
> with open ("installed.txt", "wb") as f:
>  writer = csv.writer (f)
>  writer.writerow (fields)
> for subkey in uninstall:
>  info = dict (subkey.values ())
>  writer.writerow ([info.get (field) for field in fields])
> 
>
> 
> The error message is as follows:
> Traceback (most recent call last):
>   File "C:\Python26\tim.py", line 13, in 
> writer.writerow ([info.get (field) for field in fields])
> ValueError: I/O operation on closed file
> 
>
> Any ideas on how to rectify this problem? Thanks!
>
> --
> Hotmail is redefining busy with tools for the New Busy. Get more from your
> inbox. Sign up 
> now.
>
>
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Win API call to display a BMP/PNG file as a splash screen for a console app?

2010-03-22 Thread python
Is there a Windows API call I can use to display a BMP or a PNG
file in a window centered on a user's display? This function
would be called from a console app to display a splash screen.

Motivation: I would like some of our customer facing Python
console utilities to display a splash screen. I don't need the
complexity of a full GUI framework like wxPython or pyQT and
hopefully I can avoid the need to use a full library like PIL.

Thank you,
Malcolm
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Win API call to display a BMP/PNG file as a splash screen for a console app?

2010-03-22 Thread Tony Cappellini
From: pyt...@bdurham.com
To: "zz Python Win32 Newsgroup" 
Subject: [python-win32] Win API call to display a BMP/PNG file as a
   splash screen for a console app?
Message-ID: <1269295703.32357.1366163...@webmail.messagingengine.com>
Content-Type: text/plain; charset="us-ascii"

>>Is there a Windows API call I can use to display a BMP or a PNG
>>file in a window centered on a user's display? This function
>>would be called from a console app to display a splash screen.

I don't know, but I suspect not.
>>complexity of a full GUI framework like wxPython or pyQT and
To do this in wxPython is approximately 10 lines of code, maybe 20 at the
most.
Actually- the # of lines to do this in wxPython is less than your original
email.


class SketchApp(wx.App):

def OnInit(self):
bmp = wx.Image("splash.png").ConvertToBitmap()
wx.SplashScreen(bmp, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
1000, None, -1)
wx.Yield()

frame = SketchFrame(None)
frame.Show(True)
self.SetTopWindow(frame)
return True

if __name__ == '__main__':
app = SketchApp(False)
app.MainLoop()


This is barebones, taken from wxPython In Action- ideally you should have
some minimal exception handling
to make your app more robust.
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Win API call to display a BMP/PNG file as a splash screen for a console app?

2010-03-22 Thread python
Hi Tony,

Thanks for the wxPython code. My reason for wanting to avoid
wxPython (and pyQt) is that I don't want to ship the wxPython
framework just to display a splash screen. I believe this might
triple the size of my PY2EXE generated executables - not a
worthwhile tradeoff for a cosmetic feature like a splash screen.

Regards,
Malcolm

- Original message -
From: "Tony Cappellini" 
To: python-win32@python.org
Cc: pyt...@bdurham.com
Date: Mon, 22 Mar 2010 15:47:47 -0700
Subject: Re:Win API call to display a BMP/PNG file as a splash
screen for a console app?
From: [1]pyt...@bdurham.com
To: "zz Python Win32 Newsgroup" <[2]python-wi...@python.org>
Subject: [python-win32] Win API call to display a BMP/PNG file as
a
   splash screen for a console app?
Message-ID:
<[3]1269295703.32357.1366163...@webmail.messagingengine.com>
Content-Type: text/plain; charset="us-ascii"
>>Is there a Windows API call I can use to display a BMP or a PNG
>>file in a window centered on a user's display? This function
>>would be called from a console app to display a splash screen.
I don't know, but I suspect not.
>>complexity of a full GUI framework like wxPython or pyQT and
To do this in wxPython is approximately 10 lines of code, maybe
20 at the most.
Actually- the # of lines to do this in wxPython is less than your
original email.
class SketchApp(wx.App):
def OnInit(self):
bmp = wx.Image("splash.png").ConvertToBitmap()
wx.SplashScreen(bmp, wx.SPLASH_CENTRE_ON_SCREEN |
wx.SPLASH_TIMEOUT,
1000, None, -1)
wx.Yield()
frame = SketchFrame(None)
frame.Show(True)
self.SetTopWindow(frame)
return True
if __name__ == '__main__':
app = SketchApp(False)
app.MainLoop()
This is barebones, taken from wxPython In Action- ideally you
should have some minimal exception handling
to make your app more robust.

References

1. mailto:pyt...@bdurham.com
2. mailto:python-win32@python.org
3. mailto:1269295703.32357.1366163...@webmail.messagingengine.com
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Win API call to display a BMP/PNG file as a splash screen for a console app?

2010-03-22 Thread Tim Roberts
pyt...@bdurham.com wrote:
>  
> Thanks for the wxPython code. My reason for wanting to avoid wxPython
> (and pyQt) is that I don't want to ship the wxPython framework just to
> display a splash screen. I believe this might triple the size of my
> PY2EXE generated executables - not a worthwhile tradeoff for a
> cosmetic feature like a splash screen.

Well, you're going to need a framework of some kind.  It's possible you
could make it smaller by using Tkinter, but displaying a bitmap requires
creating a window, and creating a window means you have to have a
message dispatch loop and window procedure, just like a full GUI
application.

There's really no other way.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Win API call to display a BMP/PNG file as a splash screen for a console app? [SEC=PERSONAL]

2010-03-22 Thread Andrew MacIntyre
Is it possible to draw directly to the desktop?  I vaguely recall reading 
somewhere that that is how some splash screens are done to avoid the overhead 
of a window...

-> "These thoughts are mine alone!" <-
Andrew MacIntyre   Operations Branch
tel:   +61 2 6219 5356 Communications Infrastructure Division
fax:   +61 2 6253 3277 Australian Communications & Media Authority
email: andrew.macint...@acma.gov.au    http://www.acma.gov.au/


> -Original Message-
> From: python-win32-bounces+andrew.macintyre=acma.gov...@python.org
> [mailto:python-win32-
> bounces+andrew.macintyre=acma.gov...@python.org] On Behalf Of Tim
> Roberts
> Sent: Tuesday, 23 March 2010 10:50 AM
> To: Python Win32 Newsgroup
> Subject: Re: [python-win32] Win API call to display a BMP/PNG file as a splash
> screen for a console app?
> 
> pyt...@bdurham.com wrote:
> >
> > Thanks for the wxPython code. My reason for wanting to avoid wxPython
> > (and pyQt) is that I don't want to ship the wxPython framework just to
> > display a splash screen. I believe this might triple the size of my
> > PY2EXE generated executables - not a worthwhile tradeoff for a
> > cosmetic feature like a splash screen.
> 
> Well, you're going to need a framework of some kind.  It's possible you
> could make it smaller by using Tkinter, but displaying a bitmap requires
> creating a window, and creating a window means you have to have a
> message dispatch loop and window procedure, just like a full GUI
> application.
> 
> There's really no other way.
> 
> --
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.
> 
> ___
> python-win32 mailing list
> python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32

If you have received this email in error, please notify the sender immediately 
and erase all copies of the email and any attachments to it. The information 
contained in this email and any attachments may be private, confidential and 
legally privileged or the subject of copyright. If you are not the addressee it 
may be illegal to review, disclose, use, forward, or distribute this email 
and/or its contents.
 
Unless otherwise specified, the information in the email and any attachments is 
intended as a guide only and should not be relied upon as legal or technical 
advice or regarded as a substitute for legal or technical advice in individual 
cases. Opinions contained in this email or any of its attachments do not 
necessarily reflect the opinions of ACMA.
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Win API call to display a BMP/PNG file as a splash screen for a console app?

2010-03-22 Thread Tim Roberts
Andrew MacIntyre wrote:
> Is it possible to draw directly to the desktop?  I vaguely recall reading 
> somewhere that that is how some splash screens are done to avoid the overhead 
> of a window...
>   

Yes, it's possible, but that's not the right way to do a splash screen,
because there's no good way to force the regions you overwrite to
refresh themselves.

It IS possible to do a simple GUI window using pywin32 directly.  It
isn't pretty (it's like coding to the SDK directly), but I suspect it
would do what you need.  Check in your win32\Demos directory for
win32gui_demo.py and see where that gets you.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32