Help ! Outlook Automation with outlook visible

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dittytwo
    New Member
    • Jan 2008
    • 10

    Help ! Outlook Automation with outlook visible

    hi there
    i have been tasked with automating a simple create email task using microsoft outlook.
    the code below works create unfortunately it works only at a system level i.e. the user does not see it.
    please help me make it visible
    [CODE=PYTHON]
    text="hello wolrd \nhello world this is hopefully a new paragrpah"
    subject="this is the E-mail"
    recipient="thin gy-ma-bob@hotmail.com "
    o = win32com.client .DispatchEx("Ou tlook.Applicati on.11")
    #o.Show() #<--here
    Msg = o.CreateItem(0)
    Msg.To = recipient
    Msg.Subject = subject
    Msg.Body = text
    Msg.Save()
    Msg.close
    o.Quit()
    [/CODE]
    I have tried
    o.Visible throws a com error (AttributeError : Outlook.Applica tion.Visible)
    o.Display throws a com error (AttributeError : Outlook.Applica tion.Display)
    both the above set to true gain throws a com error
    o.Show (AttributeError : Outlook.Applica tion.Show)
    all of the above with and without attributes
    If i set o.Visible =1 (i.e. True)I get the com error
    AttributeError: Property 'Outlook.Applic ation.Visible' can not be set.

    it must be possible as all other office products you can set to be visible.
    obviusly I can
    Code:
    os.system("start outlook")
    or run outlook.exe
    but that is just nasty....
    I might as well be using a Key pressing program and not bother with com
    Please help
    cheers
    D2
  • jlm699
    Contributor
    • Jul 2007
    • 314

    #2
    Originally posted by dittytwo
    o.Visible throws a com error (AttributeError : Outlook.Applica tion.Visible)
    o.Display throws a com error (AttributeError : Outlook.Applica tion.Display)
    o.Show (AttributeError : Outlook.Applica tion.Show)
    These are telling you that the object doesn't have those attributes
    Originally posted by dittytwo
    If i set o.Visible =1 (i.e. True)I get the com error
    AttributeError: Property 'Outlook.Applic ation.Visible' can not be set.
    This is telling you that this is a read-only variable, meaning there must be some method to set it to True. Perhaps there is a method that you could use like:
    o.SetVisible( True )

    Try scanning the API for Outlook COM objects

    Comment

    Working...