473,378 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Outlook Addin and py2exe: 2 problems

Hello,

I'm trying to create an addin for Outlook 2002 using the one provided
in the demo of win32com as a starting point. I've been able to do my
addin and test it if I go the "standard" way (using the python
interpreter). But now, I want other poeple to use it to I want to
freeze it for windows using py2exe and py2exe is giving me a headache.

First, I cannot seem to be able to register my addin with the resulting
executable. I've tried "directly" by creating only an executable and I
tried the same way the SpamBayes addin seems to be done, creating a dll
and registering that dll. no success.

Second, this one is more obscur and seems like a corrupt library to me.
If I import wx in my script, the executable won`t work. I get the
following error:
------------------
Traceback (most recent call last):
File "outlookAddin.py", line 39, in ?
File "SaveOMaticApp.pyc", line 4, in ?
File "wx\__init__.pyc", line 42, in ?
File "wx\_core.pyc", line 164, in ?
AttributeError: 'module' object has no attribute 'SIZE_FORCE'
---------------
outlookAddin imports SaveOMaticApp which simply imports wx. No where I
use "SIZE_FORCE" and even wx\_core.py doesn't use SIZE_FORCE. Now, I
get this error here but not on my home computer which makes me think
it's a corrupt library or something.

But I would really appreciate if someone could help be to register my
addin. Here's my addin code. Again, this work using the Python
interpreter:

-------------------- oulookAddin.py ----------------
mport win32com.server.register
import win32api
import win32com
from win32com import universal
from win32com.server.exception import COMException
from win32com.client import gencache, DispatchWithEvents
import winerror
import pythoncom
from win32com.client import constants
import sys
import os
from SaveOMaticApp import BoaApp
import database
import _winreg
# Support for COM objects we use.
gencache.EnsureModule('{00062FFF-0000-0000-C000-000000000046}', 0, 9,
0, bForDemand=True) # Outlook 9
gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2,
1, bForDemand=True) # Office 9

# The TLB defiining the interfaces we implement
universal.RegisterInterfaces('{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}',
0, 1, 0, ["_IDTExtensibility2"])

class SaveOMaticButtonEvent:
def OnClick(self, button, cancel):
import win32ui
try:
#myApp=BoaApp(0,OutlookItem=self.Parent.Parent.Cur rentItem)
#myApp.MainLoop()
pass
except:
win32ui.MessageBox("Ca marche pas" ,"My Addin")
class InspectorsEvent:
def OnNewInspector(self,inspector):
if not inspector.IsWordMail():
bars = inspector.CommandBars
toolbar = bars.Item("Standard")
for x in toolbar.Controls:
if x.Caption=="Save-O-Matic":
item = x
break
else:
item =
toolbar.Controls.Add(Type=constants.msoControlButt on, Temporary=True)
item = self.toolbarButton =
DispatchWithEvents(item,SaveOMaticButtonEvent)
item.Caption="Save-O-Matic"
item.TooltipText="Fill this item"
item.Enabled=true

class FolderEvent:
def OnItemAdd(self, item):
try:
print "An item was added to the inbox with subject:",
item.Subject
except AttributeError:
print "An item was added to the inbox, but it has no
subject! - ", repr(item)
class OutlookAddin:
_com_interfaces_ = ['_IDTExtensibility2']
_public_methods_ = []
_reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER
_reg_clsid_ = "{0F47D9F3-598B-4d24-B7E3-92AC15ED27E2}"
_reg_progid_ = "Python.Test.OutlookAddin"
_reg_policy_spec_ = "win32com.server.policy.EventHandlerPolicy"
_reg_class_spec_ = "SaveOMatic.outlookAddin.OutlookAddin"
def OnConnection(self, application, connectMode, addin, custom):
print "OnConnection", application, connectMode, addin, custom
# ActiveExplorer may be none when started without a UI (eg,
WinCE synchronisation)
#self.myInspectors =
DispatchWithEvents(application.Inspectors,Inspecto rsEvent)
activeExplorer = application.ActiveExplorer()
if activeExplorer is not None:
bars = activeExplorer.CommandBars
toolbar = bars.Item("Standard")
item =
toolbar.Controls.Add(Type=constants.msoControlButt on, Temporary=True)
# Hook events for the item
item = self.toolbarButton = DispatchWithEvents(item,
ButtonEvent)
item.Caption="Python"
item.TooltipText = "Click for Python"
item.Enabled = True

def OnDisconnection(self, mode, custom):
print "OnDisconnection"
def OnAddInsUpdate(self, custom):
print "OnAddInsUpdate", custom
def OnStartupComplete(self, custom):
print "OnStartupComplete", custom
def OnBeginShutdown(self, custom):
print "OnBeginShutdown", custom

def RegisterAddin(klass):

key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER,
"Software\\Microsoft\\Office\\Outlook\\Addins" )
subkey = _winreg.CreateKey(key, klass._reg_progid_)
_winreg.SetValueEx(subkey, "CommandLineSafe", 0, _winreg.REG_DWORD,
0)
_winreg.SetValueEx(subkey, "LoadBehavior", 0, _winreg.REG_DWORD, 3)
_winreg.SetValueEx(subkey, "Description", 0, _winreg.REG_SZ,
klass._reg_progid_)
_winreg.SetValueEx(subkey, "FriendlyName", 0, _winreg.REG_SZ,
klass._reg_progid_)

def UnregisterAddin(klass):
try:
_winreg.DeleteKey(_winreg.HKEY_CURRENT_USER,
"Software\\Microsoft\\Office\\Outlook\\Addins\ \" + klass._reg_progid_)
except WindowsError:
pass

if __name__ == '__main__':
if hasattr(sys, "frozen"):
sys.frozendllhandle = win32api.LoadLibrary("outlook_addin.dll")
pythoncom.frozen = sys.frozen = "dll"
# Without this, com registration will look at class.__module__,
and
# get all confused about the module name holding our class in
the DLL
OutlookAddin._reg_class_spec_ = "outlookAddin.OutlookAddin"
# And continue doing the registration with our hacked
environment.
import win32com.server.register
win32com.server.register.UseCommandLine(OutlookAdd in)
if "--unregister" in sys.argv:
UnregisterAddin(OutlookAddin)
else:
RegisterAddin(OutlookAddin)
----------------- setup.py -----------------------
# setup.py
from distutils.core import setup
import py2exe

outlook_addin = dict(
modules = ["outlookAddin"],
dest_base = "outlook_addin",
create_exe = False,
)

setup(name='SaveOMatic',
com_server=[outlook_addin],
console=['outlookAddin.py']
])

Mar 10 '06 #1
0 2223

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Samuel Bernard | last post by:
Hi, I created an addin for Outlook 2003. It creates a menu in Outlook in order to allow the user to access severals options of our Web site. I use MsiInstaller of MS to install this addin which...
4
by: Pete Davis | last post by:
Using this as a guide: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q302896 I am trying to implement an AddIn for outlook using C#. The sample is in VB.NET, so I assume this has to...
4
by: Nathan Carroll | last post by:
Why am I able to use this in Outlook and not do the same from .Net. My problems centers around the Items in the xp version of below i used the interop references. Does something similar exist for...
3
by: wizzbangca | last post by:
Hi everyone. Having problems with a utility I am writing for work. The previous IT Director thoughtfully allowed 3 (2000, xp, 2003) versions of outlook to be installed rather than 1. Now I need...
7
by: Joseph Geretz | last post by:
I've been working on an Addin for Outlook in C#. It hasn't been long now, just a couple of days. Suddenly though, running my project in Debug launches Outlook as specified, but no breakpoints...
6
by: Joseph Geretz | last post by:
I'm porting a C# Outlook Addin originally engineered as a COM Addin over to use VSTO. I've gotten this to the point where my VSTO Addin installs its Menu items and Toolbar buttons when Outlook...
6
by: Pieter | last post by:
Hi, I developed an Outlook Add In (VB.NET 2005, for Outlook 2003) that sometimes suddenly stops loading. I've put everywhere in the code Exception Handlers, but no Exception is catched. it...
1
by: John | last post by:
Hi I have a simple Outlook 2003 AddIn created using Outlook 2003 AddIn template in vs 2008. The full code is given below at the end. I got warnings on Interop assemblies as I have Office 2007...
5
by: John | last post by:
Hi I have an Outlook add-in solution which includes a setup project. If I install the Outlook add-in by right clicking on the setup project and sleeting Install then the add-in gets installed...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.