def OnClick(self, button, cancel): from win32com.client import Dispatch import win32con mngr = manager.GetManager() data = mngr.LoadConfig() outlook = Dispatch("Outlook.Application") ex = outlook.ActiveExplorer() if ex: is_login = str(data['login']) if is_login == 'False': win32ui.MessageBox("Please login to the database first", "OpenERP Connection", win32con.MB_ICONEXCLAMATION) elif ex.Selection.Count == 1: mngr = manager.GetManager() mngr.ShowManager("IDD_SYNC") elif ex.Selection.Count == 0: win32ui.MessageBox("No mail selected to push to OpenERP", "Push to OpenERP", win32con.MB_ICONINFORMATION) elif ex.Selection.Count > 1: win32ui.MessageBox( "Multiple selection not allowed. Please select only one mail at a time.", "Push to OpenERP", win32con.MB_ICONINFORMATION) return cancel