Stop Rule (not turn off) that Delays Outgoing Items

Status
Not open for further replies.

adavid

New Member
Outlook version
Outlook 2010 32 bit
Email Account
IMAP
I have a rule that delays outgoing items by 3 minutes. The code below works great at turning off my rule. However, if the rule delaying the mail is turned off the mail stays in the outbox for the full 3 minutes. I want it to send immediately upon the rule being turned off. Any suggestions?


Sub SendNow()
Dim olRules As Outlook.Rules
Dim olRule As Outlook.Rule

Set olRules = Application.Session.DefaultStore.GetRules
Set olRule = olRules.Item("DelaySend")

On Error GoTo err_routine

Dim x

Dim OutlookSendReceiveWasPreviouslyDisabled As Boolean
Line1: OutlookSendReceiveWasPreviouslyDisabled = Application.ActiveExplorer().CommandBars("Standard").Controls("Send/Re&ceive").Controls("Send/Recei&ve Settings").Controls("&Disable Scheduled Send/Receive").State

Line2:
Application.ActiveExplorer().CommandBars("Standard").Controls("Send/Re&ceive").Controls("Send/Recei&ve Settings").Controls("&Disable Scheduled Send/Receive").Execute
Line2b:

If OutlookSendReceiveWasPreviouslyDisabled Then
MsgBox "SendNow Enabled."
If olRule.Enabled = False Then olRule.Enabled = True
olRules.Save
Else
MsgBox "SendNow Disabled"
If olRule.Enabled = True Then olRule.Enabled = False
olRules.Save
End If

exit_sub:
Exit Sub
err_routine:
MsgBox Error$
Resume exit_sub


End Sub
 

adavid

New Member
Outlook version
Outlook 2010 32 bit
Email Account
IMAP
Never mind, true to form I figured it out right after I posted. Here is the working code:

Sub SendNow()
Dim olRules As Outlook.Rules
Dim olRule As Outlook.Rule
Dim mySyncObjects As Outlook.SyncObjects
Dim syc As Outlook.SyncObject
Set mySyncObjects = Application.GetNamespace("MAPI").SyncObjects
Set syc = mySyncObjects(1)
Set olRules = Application.Session.DefaultStore.GetRules
Set olRule = olRules.Item("DelaySend")
'If olRule.Enabled = True Then olRule.Enabled = False
'olRules.Save
'If olRule.Enabled = False Then olRule.Enabled = True
'olRules.Save
'Set olRules = Nothing
'Set olRule = Nothing

On Error GoTo err_routine

Dim x

Dim OutlookSendReceiveWasPreviouslyDisabled As Boolean
Line1: OutlookSendReceiveWasPreviouslyDisabled = Application.ActiveExplorer().CommandBars("Standard").Controls("Send/Re&ceive").Controls("Send/Recei&ve Settings").Controls("&Disable Scheduled Send/Receive").State

Line2:
Application.ActiveExplorer().CommandBars("Standard").Controls("Send/Re&ceive").Controls("Send/Recei&ve Settings").Controls("&Disable Scheduled Send/Receive").Execute
Line2b:

If OutlookSendReceiveWasPreviouslyDisabled Then
MsgBox "SendNow Enabled."
If olRule.Enabled = False Then olRule.Enabled = True
olRules.Save
syc.Start
Else
MsgBox "SendNow Disabled"
If olRule.Enabled = True Then olRule.Enabled = False
olRules.Save
syc.Start
End If

exit_sub:
Exit Sub
err_routine:
MsgBox Error$
Resume exit_sub


End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
T "Words In Recipient's Address" Rule Causes Outlook To Stop Processing Rules Using Outlook 3
A How to stop user form from disapearing once mail window is closed? Outlook VBA and Custom Forms 0
D Outlook 2016 Outlook Error Msg "The operation cannot be performed ..." How to Stop it Using Outlook 3
Y Outlook 2013 Stop Outlook from automatically assigning categories to Tasks Using Outlook 0
D Any updates or fixes that would make this code stop working just moving emails to another folder Outlook VBA and Custom Forms 1
F Outlook 2016 call to Stop Timer Event Outlook VBA and Custom Forms 4
S stop calendar date reverting to today Using Outlook 7
B Contacts just stop syncing, yesterday... Using Outlook 4
O Stop more than one person responding to an email? Using Outlook 1
A Can't stop Outlook.com from setting reminders on appointments? Using Outlook.com accounts in Outlook 3
D Stop meeting acceptance notifications Using Outlook 1
J it goes like outlook has stopped working, a problem caused the program to stop working correctly, wi Using Outlook 2
makinmyway Research Pane in Emails Turns on and Cut Paste Keys then Stop Working Using Outlook 5
J How to Stop OutLook from being Installed Using Outlook 1
A Exchange 2003 how to stop accepting EHLO and AUTH commands Exchange Server Administration 2
M Outlook 2010 IMAP rules occasionaly stop working Using Outlook 4
C How to stop iCloud calendars opening by default Using Outlook 8
icacream outlook 2007 - how do I stop spacing when I hit return ? Using Outlook 4
T Outlook 2007 SSL selfsigned certificate how to stop security popup everytime? Using Outlook 10
Y How do you stop double booking? Using Outlook 1
Commodore Why some RSS feeds stop getting updates? Using Outlook 12
N Rules stop running automatically Using Outlook 10
S Stop mail checking Using Outlook 5
M Can you stop "Microsft Office Outlook is synchronizing folders"? Using Outlook 2
C stop messages to personal folders Using Outlook 2
M Why rules stop running automatically? Using Outlook 1
J Stop Outlook 2010 from showing face pictures in From/To/Cc/Subject box Using Outlook 2
S Shared Calendar Need To Stop Receiving Other Peoples Reminders Using Outlook 3
R Stop Double Booking Rooms Using Outlook 3
C stop facebook? Using Outlook 16
A How do I get Outlook to stop adding a "+1" in front of a telephone number that has an extension. Using Outlook 13
L Outlook inbox is "always in front". How to stop that? BCM (Business Contact Manager) 1
M Stop Search folders from disabling every 1-2 days? Outlook VBA and Custom Forms 3
N VBA Procedure (or Macro) to Stop Outlook from Closing? Outlook VBA and Custom Forms 2
M Stop ribbon item tool tip text from wrapping? Outlook VBA and Custom Forms 2
D Stop automatic opening BCM (Business Contact Manager) 1
C How to stop replies in thier tracks Outlook VBA and Custom Forms 1
A stop outlook reminders generated through BCM BCM (Business Contact Manager) 3
P Can I create a Rule that sends me an email when I get a Task? Using Outlook 3
E Having some trouble with a run-a-script rule (moving mail based on file type) Outlook VBA and Custom Forms 5
M How create a Rule to filter sender's email with more that one @ sign Using Outlook 1
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
1 Incorrectly Setup a Rule at Domain level to not allow address from outside domain Exchange Server Administration 2
J Transport Rule to detect Keyword question.. Exchange Server Administration 2
R Outlook Autoforward rule do not work for NDR messages Using Outlook 1
R Setup autofoward rule on a particular folder in Outlook Using Outlook 0
N Rule for "on behalf of" - with changing names Using Outlook 2
S Unable to remove rule outlook 2010 Using Outlook 0
O Outlook 2016 This rule will only run when you check your email in Outlook.... Using Outlook 4
Nadine Rule to move attachments with specific name Outlook VBA and Custom Forms 1

Similar threads

Top