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.
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.
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.
@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.
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)
Bookmarks