How to flush outlooks open connection

S

Sam Jost

Is there a way to flush outlooks cache?

I'm adding a lot of contacts in a public folder, then I want to close
outlook, but flush its write cache or whatever it is first.

Using olNamespace.logoff and olApp.Quit does not flush these caches. Is
there any other command I am missing?

Thanks,
Sam
 
K

Ken Slovak

What language, what version of Outlook, are you using Exchange?

Flushing the cache is not available but if you are closing Outlook then the
cache should be flushed by that action, assuming that Outlook isn't hung in
memory.
 
S

Sam Jost

Hi Again :)

Using c#, Outlook 2003 and Exchange 2003 (SBS 2003) for the public folder.

Closing Outlook (namespace.Logoff() and outlook.Quit()) and opening it anew
does not flush the cache for me.

The exact source I'd been using to flush was:
--
outlookNamespace.Logoff();
outlookApp.Quit();
outlookApp = new Outlook.Application();
outlookNamespace = outlookApp.GetNamespace("mapi");
outlookNamespace.Logon("", "", true, true);
outlookKontaktFolder = outlookNamespace.GetFolderFromID( FolderEntryID,
StoreEntryID);
--

and it did not flush the cache, the objects are still pending on this new
instance of Outlook.

Sam
 
K

Ken Slovak

You seem to have solved it based on your other thread but always remember to
explicitly release all your objects and calling the garbage collector.
 
S

Sam Jost

I thought so, too, but it turned out that closing outlook did not flush
these things.

So I'm still looking for some way to flush outlooks caches, to make it sync
completely and close I'd guess?

Or some other way to read and import lots of data to Exchange public
folders, thats what I need the flush for.

Can maybe Exchange (2003) itself be called/scripted from c# on the server?

Sam
 
K

Ken Slovak

As I recall it's a timing issue if you don't explicitly release all your
objects. I think Exchange just holds open those RPC connection channels for
a considerable time. But since I refuse to code Outlook in VB.NET or C# I'm
not positive.

The language isn't so much the issue as the API you use. You can connect to
an Exchange server using lots of different API's, some of which are
supported for C#, such as WebDAV or ADO or CDO 1.21 or Extended MAPI and so
on. I don't think you can close those RPC channels that are affecting your
code using any programmatic access as far as I know though.
 
S

Sam Jost

Hi Ken,

yep, you are right, the problem does appear when not releasing my objects,
and some timeout takes care of it after a looong time.

Well, anyway, problem is solved now, thanks a lot again!
Sam
 
G

Guest

Here's an example: (ns is your already obtained namespace)

Dim objSycs As Outlook.SyncObjects
Dim objSyc As Outlook.SyncObject
Dim fldContacts As Outlook.MAPIFolder
Dim fldNotes As Outlook.MAPIFolder

Try
objSycs = ns.SyncObjects
objSyc = objSycs.AppFolders
fldContacts =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
fldContacts.InAppFolderSyncObject = True
fldNotes =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderNotes)
fldNotes.InAppFolderSyncObject = True
objSyc.Start()
 

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