Outlook Sync Outlook Inbox with Exchange Server without opening Outlook (using VBA)

Joined
Jan 30, 2013
Messages
2
Reaction score
0
I was wondering if anyone knows how to sync their Outlook inbox folders with Microsoft Exchange Server without actually opening Outlook?

Thus far, I am able to create an Outlook session and view all of my emails in Inbox via Excel VBA:

Code:
Sub CHECK_EMAIL_AND_RUN()
    Dim myOlapp As Outlook.Application
    Dim myNameSpace As Outlook.Namespace
    Dim myTopFolder As Outlook.MAPIFolder
    Dim myFolder As Outlook.MAPIFolder
    Dim destFolder As Outlook.MAPIFolder
    Dim myItem As Outlook.MailItem
    Dim myAttachment As Outlook.Attachment


    Set myOlapp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlapp.GetNamespace("MAPI")
    Set myInboxFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
    
    


 For Each myItem In myInboxFolder.Items

'do some stuff


Next

End sub

However, assuming that Outlook is closed prior to running this code and I send an email to the Inbox, the email will not appear in the Inbox until I actually open Outlook and let it sync with the Exchange Server.

I would have thought that by creating an Outlook session, ie:
Code:
Dim myOlapp As Outlook.Application
this would allow emails to sync with the Exchange Server but this is not the case.

Does anyone know how to sync Outlook with the Exchange Server while Outlook is closed?

Thanks,

Katie :wave:
 
Joined
Mar 20, 2012
Messages
764
Reaction score
4
Sorry, but what is it you are looking to get out of this? If you are running Outlook in Cached Exchange Mode, the Outlook client needs to be running to download the emails to the OST, and OST files are very picky about letting more than one process access them if you're trying to access the OST with another program, but have Outlook do the syncing for you. If you're running Outlook without Cached Exchange Mode, it doesn't download the emails locally, it simply displays what's on the server in an "Online" mode.
 
Joined
Jan 30, 2013
Messages
2
Reaction score
0
Hi alow,

I have a scheduled task that will run a VBA macros every minute to check if an email (with a specific subject) exists, and if it does, initiate another macros. This will be running 24/7 on a dedicated computer so I wish to have Outlook closed if possible because leaving it open for extended periods of time can create some problems.

Given that my OST file is considerably large, I believe that my Outlook is running in Cached Exchange Mode.

Based on your response, I need a way of updating the OST file without having Outlook open. Alternatively, do you know of any VBA code that lets me loop through each email directly off the server?

Thanks,

K :D
 
Joined
Mar 20, 2012
Messages
764
Reaction score
4
VBA is not my strong point, but with what I know of Exchange and Outlook, I would say that what you're trying to do isn't possible. I would suggest using Outlook and just setting up a Rule to do a certain action when a particular email comes through. If you're really looking for a way to do it without Outlook, good luck!
 

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