Q: CDO or Outlook?

  • Thread starter Thread starter Joseph Kormann
  • Start date Start date
J

Joseph Kormann

I'm building an application to retrieve emails. Which is better to use: CDO
or the Outlook library?

Thanks.
 
Any help here? I've spent a number of hours researching and all I found is
the msdn website is highly recursive.

I want to tie my application to either the local Outlook server or to the
foreign Exchange server. I can get the app to talk with the Outlook
(sometimes it doesn't change the Read/Unread flag) but I'm still trying to
get it to talk with the foreign Exchange server.
 
Joseph,
The 'best' list of resources that I am aware of for combining .NET & Outlook
(CDO) is:
http://www.microeye.com/resources/res_outlookvsnet.htm

What do you mean by 'Outlook Server'? Do you mean a local Exchange Server
verses a Foreign Exchange Server? I don't use Exchange Server, however to
the best of my knowledge Outlook can only connect to a single Exchange
server at a time.

Hope this helps
Jay
 
Jay B. Harlow said:
Joseph,
The 'best' list of resources that I am aware of for combining .NET & Outlook
(CDO) is:
http://www.microeye.com/resources/res_outlookvsnet.htm

Yes, this was a very helpful link which got me to connect to the Outlook
running on my workstation.

And do you have any idea as to why when my application sets a an unread
message to 'unread = false', it sometimes doesn't get set in the Outlook
gui? It's like it get skipped. Very puzzling. (I noticed the MVP - Outlook
and thought you could answer that one).
What do you mean by 'Outlook Server'? Do you mean a local Exchange Server
verses a Foreign Exchange Server? I don't use Exchange Server, however to
the best of my knowledge Outlook can only connect to a single Exchange
server at a time.

I mean the remote MS Exchange server that my Outlook gets it's messages
from. Or is the only way through the SMTP object set? The only problem there
is I can't mark the message as read so I can get redundant messages.
Hope this helps
Jay

appreciate any help,
Joseph
 
Joseph,
And do you have any idea as to why when my application sets a an unread
message to 'unread = false', it sometimes doesn't get set in the Outlook
gui? It's like it get skipped. Very puzzling.
After you set the Unread to false, you need to save the item. Also I would
do a System.Runtime.InteropServices.Marchal.ReleaseComObject as soon as I
was done with the com object, to ensure it gets released in a timely manner,
otherwise you are at the discretion of the GC.
I mean the remote MS Exchange server that my Outlook gets it's messages
from. Or is the only way through the SMTP object set? The only problem there
is I can't mark the message as read so I can get redundant messages.
Let me reword the question: How many Exchange Servers are involved?
(I noticed the MVP - Outlook and thought you could answer that one).
I spend more time in .NET nowadays over programming Outlook, I try to answer
Outlook questions as best as I remember ;-)

Hope this helps
Jay
 
Jay B. Harlow said:
Joseph,
After you set the Unread to false, you need to save the item. Also I would
do a System.Runtime.InteropServices.Marchal.ReleaseComObject as soon as I
was done with the com object, to ensure it gets released in a timely manner,
otherwise you are at the discretion of the GC.

Excellent advice. I'll try it and let you know the results.
Let me reword the question: How many Exchange Servers are involved?

As far as I know, one.
 
Jay B. Harlow said:
Joseph,
After you set the Unread to false, you need to save the item. Also I would
do a System.Runtime.InteropServices.Marchal.ReleaseComObject as soon as I
was done with the com object, to ensure it gets released in a timely manner,
otherwise you are at the discretion of the GC.

One item of interest, if the application does not logoff and I don't
deregister my events from the Outlook, it causes massive (!) problems down
the line. I am able to close my Outlook GUI but the Outlook background
application still runs. Then I get the problem of not being able to properly
manage the emails. A destructor and Dispose method (to properly stop my
interface class) seems to solve that, but if the application terminates
early, Outlook still has that problem. Other than manually stopping the
Outlook background application, is there a way to clear those previous
registrations?

The .Save and ReleaseComObject are very handy. Thank you.
 
Joseph,
but if the application terminates
early, Outlook still has that problem.
What do you mean "terminates early", do you mean you had an unhandled
exception & exited?

Or you closed all your forms and did a mostly clean, but not completely
clean exit?

For an unhandled exception:
Depending on the type of application you are creating, .NET has three
different global exception handlers.

For ASP.NET look at:
System.Web.HttpApplication.Error event
Normally placed in your Global.asax file.

For console applications look at:
System.AppDomain.UnhandledException event
Use AddHandler in your Sub Main.

For Windows Forms look at:
System.Windows.Forms.Application.ThreadException event
Use AddHandler in your Sub Main.

For a not completely clean exit, the AppDomain.ProcessExit and/or
Application.ApplicationExit events may help.
Other than manually stopping the
Outlook background application, is there a way to clear those previous
registrations?
Not that I am aware of.

Hope this helps
Jay
 
Jay B. Harlow said:
Joseph,
What do you mean "terminates early", do you mean you had an unhandled
exception & exited?

Tried all the Handlers you suggested. They appear to work very well but not
what's happening. :)
It's a console application and I'm hitting the Close ("X") in the
upper-right corner of the console window. It's still exiting with an
error-code of 0, but it's not calling the destructors and dispose methods.

It's not a completely clean exit, but the application thinks it is. The
ProcessExit works fine when I let it die naturally - it doesn't work when I
hit the Console Close button.

Not that I am aware of.
Thanks.


Hope this helps
Jay

You've been most helpful. Thank you.
 
Joseph,
It's a console application and I'm hitting the Close ("X") in the
upper-right corner of the console window. It's still exiting with an
error-code of 0, but it's not calling the destructors and dispose methods.
It won't either!

You terminated the Win32 process, my understanding .NET does not track this
and simple lets it terminate. No chance for cleanup.

Not sure what to suggest, except "don't do that" ;-)

Hope this helps
Jay
 
Can you hook that message loop in some way? In that event would you not get
a message prior to terminating? It would be a cludge at the least, but seems
like something the VB6 gurus used to pull off all the time.

Eric Cadwell
http://www.origincontrols.com
 
Eric,
You might be able to, however console applications do not have a message
loop, per se.

I don't know enough about Win32 Console Applications to know if there is
something via P/Invoke you can do to determine if the user closed the
Console windows, thus terminating the app...

Hope this helps
Jay
 
The news.microsoft.com is acting funny, but using groups.google.com, I was
able to see the reference to Lion Shi's CTRL-Break Handler snippet. It works
well. The only difficulty that I had was the system event comes in on a
sub-thread and I had to make allowances for the sub-thread termination. The
sub-thread (which catches the event) sets a flag that the main processing
thread can read and causes it to deregister from Outlook. This ment I needed
a 100 milisecond Sleep before I could allow the sub-thread to finish it's
termination which then forces the application to terminate.

Thanks to all!
 
Back
Top