Enable all rules from toolbar button?

Status
Not open for further replies.

soadfan

Member
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
Hello there,
i have this issue which is described HERE (a screenshot of a MSO forum's thread)


Just for info i've added and 3 sec delay, but no luck:

Code:
Public Sub saveAttachtoDiskNL(itm As Outlook.MailItem)
Debug.Print "*** START NL_STT"
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim dateFormat
Dim yearFolder
dateFormat = Format(itm.ReceivedTime, "dd-mm-yyyy_hh-mm-ss-AMPM_")
yearFolder = Format(itm.ReceivedTime, "yyyy-mm")
saveFolder = "D:\TLC\STT_NL\" & yearFolder & "\"
On Error Resume Next
MkDir saveFolder
On Error GoTo 0
  For Each objAtt In itm.attachments
  Debug.Print "Found: " & objAtt.FileName & " at " & dateFormat
  If LCase(Right(objAtt.FileName, 4)) <> ".jpg" And LCase(Right(objAtt.FileName, 4)) <> ".png" Then
  Debug.Print "Confirmed as acceptable file type: " & objAtt.FileName & " at " & dateFormat
  objAtt.SaveAsFile saveFolder & dateFormat & "STT_NL" & LCase(Right(objAtt.FileName, 4))
  Debug.Print "Successful save: " & objAtt.FileName & " at " & dateFormat
  Debug.Print "Before wait:"; Now
  Call WaitFor(3)
  Debug.Print "After wait:"; Now
  Set objAtt = Nothing
  Debug.Print "Set objAtt = Nothing"
  Debug.Print "-------------------------------------------------------------------------------------------"
  End If
  Next
End Sub

and log:

Code:
*** START NL_STT
Found: WORKBOOK_4YX80QR9J004S642E8Q6AYLNX.ZIP at 16-06-2016_06-34-10-AM_
Confirmed as acceptable file type: WORKBOOK_4YX80QR9J004S642E8Q6AYLNX.ZIP at 16-06-2016_06-34-10-AM_
Successful save: WORKBOOK_4YX80QR9J004S642E8Q6AYLNX.ZIP at 16-06-2016_06-34-10-AM_
Before wait:Mon 16 June 06:34:38 AM
After wait:Mon 16 June 06:34:41 AM
Set objAtt = Nothing
-------------------------------------------------------------------------------------------

Now if i can't make it w0rk i want to be able to enable all disabled rules with one click.
Can anyone help with code for this?

P.S. I tried few google results and tried to adapt them to my needs, but also with no luck

Best regards,
Peter
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I would not delay the macro, at least not within the rule script. It causes outlook to wait and if two messages arrive at once, rules may not run on it.

I would use the rule's script to call the macro that does the work. This passes the work to a macro outside of the rule. It helped when i categorized Yammer messages based on the yammer group - failure rate dropped a lot, but there were still a few failures. (I received hundreds of messages a day from yammer, so it was always running.)


Code:
Public Sub saveAttachtoDiskNL(itm As Outlook.MailItem)
myMacro itm
End Sub

Public Sub myMacro(itm As Outlook.MailItem)
Debug.Print "*** START NL_STT"
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim dateFormat
Dim yearFolder
dateFormat = Format(itm.ReceivedTime, "dd-mm-yyyy_hh-mm-ss-AMPM_")
yearFolder = Format(itm.ReceivedTime, "yyyy-mm")
saveFolder = "D:\TLC\STT_NL\" & yearFolder & "\"
On Error Resume Next
MkDir saveFolder
On Error GoTo 0
  For Each objAtt In itm.attachments
  Debug.Print "Found: " & objAtt.FileName & " at " & dateFormat
  If LCase(Right(objAtt.FileName, 4)) <> ".jpg" And LCase(Right(objAtt.FileName, 4)) <> ".png" Then
  Debug.Print "Confirmed as acceptable file type: " & objAtt.FileName & " at " & dateFormat
  objAtt.SaveAsFile saveFolder & dateFormat & "STT_NL" & LCase(Right(objAtt.FileName, 4))
  Debug.Print "Successful save: " & objAtt.FileName & " at " & dateFormat
  Set objAtt = Nothing
  Debug.Print "Set objAtt = Nothing"
  Debug.Print "-------------------------------------------------------------------------------------------"
  End If
  Next
End Sub

The original thread is here - [Q]Outlook VBA macros running random

This macro runs rules now: Run Rules Now using a Macro
 

soadfan

Member
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
Thanks, i'll try this
Well it fails too from time to time. So...can you help with VBA which enable all rules from a toolbar button?
I have 25+ rules and it's really annoying to re-enable disabled upon fail.

Best regards,
Peter
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
G To enable/disable Allow New Time proposals Outlook VBA and Custom Forms 1
Mark Foley Cannot enable add-in in outlook 2010 Using Outlook 0
Peter H Williams Enable script containing VBA Outlook VBA and Custom Forms 12
A How to enable outlook room finder (outlook connector (mapi)) user ? Using Outlook 3
Diane Poremsky Mail-enable Exchange Public Folders Using Outlook 0
R Enable Office 365 Exchange Online Archive Using Outlook 0
R Enable Office 365 Exchange Online Archive Using Outlook 6
G VBA code to enable a rule based on time of day for a IMAP mail account Outlook VBA and Custom Forms 14
K Macro won't consistently re-enable Outlook VBA and Custom Forms 2
Sarge USMC how do I enable hyperlinks in Outlook 2013 Using Outlook 1
A how to install or enable categories in OL 2013 for calendar and contacts Using Outlook 5
D How do I mail-enable a Public Folder Sub-folder in exchnage 2007 using shell ? Exchange Server Administration 0
H enable textboxes and buttons from received email Using Outlook 1
D How To Enable Undo in Outlook 2007 Tasks Using Outlook 2
S Outlook 2010: How do you enable Contacts' Activities to search archive folders Using Outlook 6
J OL2003 Macro disables itself - looking for way to automate 'enable' Using Outlook 2
J Re-enable the junk mail notification. Using Outlook 6
C How do I enable a link in an e-mail in Outlook 2007? Using Outlook 4
A how to enable macro for addin Outlook VBA and Custom Forms 3
J Enable Sonicwall Outlook VBA and Custom Forms 1
S How do I enable administrator access in Business Contact Manager? BCM (Business Contact Manager) 1
S How to enable scripts to run in a custom form which is forwarded ? Outlook VBA and Custom Forms 1
K How do I eliminate the "Enable Macro" selection? Outlook VBA and Custom Forms 16
C Eliminate need for "Enable Macro" selection Outlook VBA and Custom Forms 7
J Office Ultimate- My outlook doesn't have BCM, how do I enable? BCM (Business Contact Manager) 1
J Recover server side rules from OST/PST without access to the server Using Outlook 2
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
N Outlook 2021 'Run Script" Rules? Outlook VBA and Custom Forms 4
K Multiple Rules on Single Email Using Outlook 2
Aussie Rules Run a Script on an Incoming Email OK and then the Email reverts Outlook VBA and Custom Forms 0
R rules not working - done troubleshooting Using Outlook 0
P Outlook 2013 All imported Mail Rules in error when imported into new profile Using Outlook 5
A Apply Selected Emails to outlook rules and Run Rules Using Outlook 5
Wayne Outlook locks up when opening "Manage Rules & Alerts" Using Outlook 7
T "Words In Recipient's Address" Rule Causes Outlook To Stop Processing Rules Using Outlook 3
Retired Geek Junk Folder Clean Up Rules Exchange Server Administration 1
B Setting rules Using Outlook 1
A rules not working Using Outlook 2
M Rules and autoreply Using Outlook 1
N Outlook rules don't create a copy for bcc'ed emails Using Outlook 3
O How to recover rules after switch from POP3 to IMAP Using Outlook 2
N Focussed Inbox Rules Failing Using Outlook 5
N Copies of emails from rules have wrong from: account Using Outlook 0
L Office 365 cloud based rules Using Outlook 1
K Outlook Rules: Move a Copy Using Outlook 4
CWM030 Rules disappearing in OL 2016? ( Yes, I searched before posting) Using Outlook 7
R When rules lose track of "specified folder" Using Outlook 6
I Outlook 2013 Rules - (client only) Using Outlook.com accounts in Outlook 1
B When I add more search strings to RULES, it is not processing them Using Outlook 3
O Having rules run on old mails noved to inbox Outlook VBA and Custom Forms 8

Similar threads

Top