Email not leaving Outbox when using Excel VBA to sync Outlook account

Oprocon

Member
Outlook version
Outlook 2019 32-bit
Email Account
Outlook.com (as MS Exchange)
Hi everybody, I've just joined this forum - thanks for having me and I need some of your expertise, if you don't mind...

My situation:
I have a single outlook.com exchange account added to Outlook 2019. By default, when I go into Send/Receive Groups, All Accounts, Edit..., the tickbox for "Include the selected account in this group" is UNTICKED. However, I have no problem sending and receiving emails when I press F9 (I have "Send immediately when connected" unticked). So, even though I don't really understand why my emails send and receive despite that account not being in the All Accounts Send/Receive Group, I'm not worried because normal F9 send/receive seems to work ok for me anyway.

Now, I've written some code in Excel to automatically generate and send an email through my Outlook account and I use GetNamespace("MAPI").SyncObjects to initiate the sync process (i.e. simulating a manual F9 press). If I change "Include the selected account in this group" to TICKED, the email sends as it should and ends up in the Sent Items folder. All good...

My problem:
I need to be able to deploy my Excel-based macro across a number of unattended computers which have "Send immediately when connected" unticked and which have the default email account UNTICKED in "Include the selected account in this group" (just like the setup on my own computer).
However, If I run my Excel macro with "Include the selected account in this group" UNTICKED, SyncObjects has no effect and the email gets stuck in the Outbox until I press F9 manually. So, this leads me to conclude that SyncObjects doesn't really do the same thing as F9.

My questions:
  1. Is there a way, programatically, to 'finish sending' any emails stuck in the Outbox which didn't get sent by SyncObjects because they were from an account that's not included in a Send/Receive Group and "Send immediately when connected" is unticked? Maybe some sort of purge method?
  2. Is there another way to fully send an email programatically that uses a different method to SyncObjects and which isn't impacted by whether or not the account is part of a Send/Receive Group?
I really appreciate you reading this and, if you have any ideas, I would be most grateful indeed! Many thanks... Oprocon
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
By default, when I go into Send/Receive Groups, All Accounts, Edit..., the tickbox for "Include the selected account in this group" is UNTICKED.
This is normal for Exchange accounts - the send/receive settings do not apply to Exchange accounts. With exchange you are constantly syncing unless you have outlook set to work offline.

As for your questions, i will need to test a few things.
 

Oprocon

Member
Outlook version
Outlook 2019 32-bit
Email Account
Outlook.com (as MS Exchange)
Diane, thank you for explaining the Exchange syncing principle - I hadn't realised that!

i will need to test a few things
Would it help you if I uploaded an Excel file containing the code I've been using, for demo purposes?
 
Top