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
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