VB6 Outlook 2007 automation
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: VB6 Outlook 2007 automation

  1. #1
    Join Date
    Sep 2009
    Posts
    4

    VB6 Outlook 2007 automation

    Hello,

    We have a large VB6 application in our enterprise which normally occupies ~30 MB of RAM.
    We have some simple outlook automation in the application, which opens a new message window.
    Code reproduced here.
    <<
    Dim objOutlook As Outlook.Application
    Dim objMailItem As Outlook.MailItem

    Set objOutlook = CreateObject("Outlook.Application")

    Set objMailItem = objOutlook.CreateItem(0) 'The constant olMailItem = 0
    objMailItem.To = Recipients
    objMailItem.Attachments.Add strAttachment
    objMailItem.Display

    Set objOutlook = Nothing
    Set objMailItem = Nothing
    >>

    The application works fine with Outlook 2003. With outlook 2007, I get the error 429 "ActiveX component can't create object".

    This error doesn't come when I use the same code in a sample application, but comes when used in the large application.

    Does VB6 impose any limitations on the process size, which could be leading to this error?


    Please also let me know if there are any other ways of achieving the same functionality without resorting to the outlook 12.0 library.

    Thanks in advance.

    Cheers,
    Kiran

  2. #2
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,854

    Re: VB6 Outlook 2007 automation

    It sounds like you haven't added a Reference to OUTLOOK 2007 in your large application

    A reference to OUTLOOK 2003 just may not be doing the job

  3. #3
    Join Date
    Sep 2009
    Posts
    4

    Re: VB6 Outlook 2007 automation

    @George1111

    I am adding the reference. Infact, the outlook object gets created if I initialize it at the beginning of the large application (say X). The problem comes only if I initialize the outlook object after X got completely initialized and running.

    The problem here is that even if I open outlook object at the beginning of X , it gets closed if the user closes outlook outside of the application. So I need the ability to create the outlook object when X is up and running.

    Please let me know if I am not clear.

    Thanks,
    Kiran

  4. #4
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,854

    Re: VB6 Outlook 2007 automation

    So you are saying that actually it is working perfectly until a user opens up Outlook on the same machine ?

    BUT

    If you work with Outlook 2003 this problem doesn't happen ?

    My experience with automation of Office products is that it gets a little screwed up if multiple instances of eg, Excel are running simultaneously

    Perhaps the new versions of Office dont like multiple instances at all

    I think you better look at this which makes reference to the problem you are having

    http://support.microsoft.com/kb/257757

  5. #5
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,999

    Re: VB6 Outlook 2007 automation

    He might be saying that app X loses it's Outlook object when the user closes Outlook, started after his app is running.

    The problem here is that even if I open outlook object at the beginning of X , it gets closed if the user closes outlook outside of the application. So I need the ability to create the outlook object when X is up and running.
    Is that close?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Sep 2009
    Posts
    4

    Re: VB6 Outlook 2007 automation

    @dglienna
    Yes. That is what I meant. The app loses it's outlook object when user closes outlook started outside the app.

    @George1111
    App X can create Outlook 2003 object when it's up and running. So it was never a problem. Even if the user closes outlook outside of the application, I can always create a new outlook object.
    The problem comes when we try to instantiate outlook 2007 object after the app is fully loaded.

    Thanks for the link. While the content there was helpful, it didn't address my immediate problem.

  7. #7
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,999

    Re: VB6 Outlook 2007 automation

    You can check if it's running, and even get it's handle. From there, you could maximize it. More work, but should get the right results.

    Not sure about automating email activities. Still pretty locked down.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,854

    Re: VB6 Outlook 2007 automation

    I found one reference to automating Outlook which had more than 10 instances running, but as you added an email to one of them, all 10 showed the email - this suggests that while you "think" you have 10 instances, there is in fact only one real instance - this then follows when you close one , you just may be closing ALL (which is what seems to be your problem)

    Regardless ....

    What may solve your problem is finding ANOTHER way to get into Outlook to do what you may want to do

    Google Search on "Outlook Redemption" which is a way of working with Outlook without having to use Outlook Automation

    Alternately, depending on how your email is delivered, you may be able to get by with just a simple POPMail VB6 Client (which can read your email accounts without going through Outlook)

  9. #9
    Join Date
    Sep 2009
    Posts
    4

    Re: VB6 Outlook 2007 automation

    Thanks for the replies. I have already checked Outlook Redemption. As far as I know, it cannot be used to display outlook message items.

    I will explore more about Outlook Redemption/POPMail VB6 client and get back here.

  10. #10
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,999

    Re: VB6 Outlook 2007 automation

    Or, you could get the VSTO Package from MSDN. Visual Studio Tools for Office That allows automation.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center