CDO api question

A

Airconditioned

Hi there. If you know of a better group to post this question please let me
know.

I am using CDO in a program to access a mail box and perform some stuff.
Anyways, I found that after debugging the messages read, the program only
sees old messages in the Inbox. I think this is a caching problem. Any
suggestions?

This CDO.dll is version 1.2.1, Exchange 2003 and the client is Outlook 2003.
 
K

Ken Slovak - [MVP - Outlook]

Are you piggy-backing onto an Outlook session or are you creating a new CDO
Session?

Do you have a MessageFilter set on Inbox? What happens if you explicitly
clear any MessageFilter?

Is Outlook installed on that machine?

If you are piggy-backing onto an Outlook session does it change behavior if
you change from cached mode to online mode or vice versa?
 
A

Airconditioned

Hi Ken.
I am new at using CDO API.
I am creating a new session.
I am not using MessageFilter but maybe I should try it.
Outlook is installed on the same machine that the program is.
What is "cached mode" and "online mode"?
I was thinking of downloading and installing the current verion of CDO.dll.
Would this help?
I am told that this program recently as last year did not have this probem
and it was reading messages fine.
Thanks for your help!
 
K

Ken Slovak - [MVP - Outlook]

If Outlook is running when you run your CDO code you really should piggyback
on that session. You do so by passing the logon as follows (assuming
oSession is your CDO.Session object):

oSession.Logon "", "", False, False

Cached and online modes are different ways that Outlook can talk to Exchange
server. Cached mode uses an OST file and synchs with the server at
intervals, online mode talks "live" with the server.

If you haven't set any MessageFilter you don't need one, that was a
possibility of why not all items were showing up for you.

CDO is specific to the Outlook version. If you are using Outlook 2003 you
can only use the version of CDO tailored to that version of Outlook. Same
thing for CDO for Outlook 2007.

CDO for earlier versions of Outlook comes on the Office CD. For Outlook 2007
it has to be downloaded from MS. If Outlook is installed on a machine you
never should use the server side version of CDO, only use the client
version. Otherwise you stand a good chance of messing up Outlook.

What makes you think you are having a caching problem, and define what you
mean by having a caching problem. I'm curious since you don't know about
cached or online modes, so what led you to the conclusion that you have that
problem?

For a good general reference for CDO and lots of code samples see
www.cdolive.com.

CDO is being deprecated and has security issues in the client version, it
will fire the security prompts for any restricted property or method, and in
many cases it will just fail without any prompt, just an error. I don't
think I'd recommend any new or extended development using CDO at this point
in time.
 
A

Airconditioned

Thanks for your input Ken!
My program that is accessing the Outlook 2003 Inbox, is a scheduled task
early in the morning, so no one else should be accessing it via Outlook. But
during the day people may be accessing it. I mention a possible caching issue
because when I look at the log file, the messages being read are old and are
actually not in the Inbox anymore. Yes that is weird. I was told this was
working fine around last year. Should I download this newest version of
CDO.dll? I am still not sure what to do. Is this a caching issue then? I see
that the Outlook has 'Use Cached Exchange Mode' unselected.
 
K

Ken Slovak - [MVP - Outlook]

If cached mode is not selected then online mode is used, so that eliminates
any caching issues that I can see.

If this is the same version of Outlook and you already have CDO installed
then you don't need to download anything. Besides, as I indicated, the CDO
version is tied to the Outlook version and the download is for Outlook 2007.
Trying to use that with Outlook 2003 is a recipe for even more problems.

I'd say what you need to look at is what changed since it worked correctly.
Certainly if you access a mailbox while Outlook has it opened and changes
are made to items in Outlook you'd need to re-read the Messages collection
of Inbox to ensure you have the latest collection, but that would have been
the same before when the code was working correctly.
 
A

Airconditioned

Unfortunatly the program has no versioning. I am not sure what to do. Can you
scan the following snippet of code and let me know if anything is missing or
something, the code is in a language called Progress ABL:

CREATE "MAPI.SESSION" objSession.
objSession:Logon(D-profile).
ASSIGN objInbox=objSession:Inbox:Messages.
objInBox:SORT(1).
ASSIGN objMessage=objInBox:GetFirst() NO-ERROR.

REPEAT ON ERROR UNDO, LEAVE:
IF is-first = FALSE THEN DO:
/*release object objMessage no-error.*/
ASSIGN objMessage=objInBox:GetNext() NO-ERROR.
END.
ELSE
ASSIGN is-first = FALSE.

ASSIGN t-subject=objmessage:subject NO-ERROR.
/*debug subject of message */
....

RELEASE OBJECT objInbox no-error.
RELEASE OBJECT objStore no-error.
RELEASE OBJECT objFolders no-error.
RELEASE OBJECT objFailed no-error.

RELEASE OBJECT objSource no-error.
RELEASE OBJECT objAttach no-error.
RELEASE OBJECT objMessage no-error.
RELEASE OBJECT objSession no-error.
objSession:Logoff.

That is probably as far as you need to see I think. Any suggestions?
 
K

Ken Slovak - [MVP - Outlook]

No idea. If it worked before and doesn't now, something changed. As to what
changed I haven't a clue.
 
A

Airconditioned

Hi Ken. I am still wondering about this problem of my program not "seeing"
the messages in my Inbox. But then sometimes it does. Since my program
accesses the mail box via MAPI to the server store it could not be a Outlook
setup settings issue right?
 
K

Ken Slovak - [MVP - Outlook]

If you are logging into the mailbox directly on the Exchange server and
running from Outlook or an Outlook session then it shouldn't be related to
Outlook. If you are running in an Outlook session you will only see what
Outlook sees.

Outlook view filters or settings for a folder view will not affect CDO's
ability to access all Messages in a folder however, that only has affect on
the user interface.
 
A

Airconditioned

Hi Ken. Yes I found the solution. My program is using a Mail Profile (one
that is not the typical Outlook entry). Curiously I looked at the profile
settings, and Use Cashed Exchange Mode was selected. So I unselected it and
the program now works fine and it sees all current messages in the Inbox.
Thanks also for your help Ken.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top