Hsu. Victor (GSM) wrote:
>         I fixed it by doing some modification.
>
> data_source_name = os.path.abspath('recipient.csv')
> mm.OpenDataSource(data_source_name)
>
> And the "Word Merge To Document" function works now.
> However, my intention is to send an email.  So I change some setting,
>
> #send the merge result to Email
> mm.Destination = win32com.client.constants.wdSendToEmail
> #send the merge result to document
> #mm.Destination = win32com.client.constants.wdSendToNewDocument
> mm.MailSubject = "This is a test mail from Python 
> Win32---"+time.strftime('%Y_%m_%d')
>
> but now, it failed to run again.
> ==================
> F:\MyProgram\python\Word2Email>python Word2Email.py
> Traceback (most recent call last):
>   File "Word2Email.py", line 41, in <module>
>     mm.Execute()
>   File 
> "F:\Python27\lib\site-packages\win32com\gen_py\00020905-0000-0000-C000-00
> 0000000046x0x8x5.py", line 14162, in Execute
>     return self._oleobj_.InvokeTypes(105, LCID, 1, (24, 0), ((16396, 
> 17),),Pause
>
> pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft 
> Word'
> , u'\u6c92\u6709\u78ba\u5b9a\u5730\u5740\uff0cWord 
> \u7121\u6cd5\u5408\u4f75\u53e
> f\u4f9b\u90f5\u5bc4\u6216\u50b3\u771f\u7684\u6587\u4ef6\u3002\u8acb\u9078\u64c7
> [\u8a2d\u5b9a] 
> \u6309\u9215\uff0c\u9078\u53d6\u90f5\u5bc4\u5730\u5740\u8cc7\u659
> 9\u6b04\u4f4d\u3002', u'wdmain11.chm', 25110, -2146822658), None)

-2146822658 is 0x800A15FE, which is "Word cannot merge documents that
can be distributed by mail or fax without a valid mail address."   My
guess is that's what the Unicode string in there is trying to tell you.

Where did you expect the email to go?

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

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

Reply via email to