Outlook 2010 Rule Ignores VBA Script

Status
Not open for further replies.

dweller

New Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Hi, I am a newbie to this forum and hope that someone can solve my problem. I have been running an Outlook Rule that copies specific inbox emails to another folder and then calls a script that copies the attachment of each email to my local DropBox folder. The rule is activated whenever an email with the right sender arrives in the inbox.

This rule worked perfectly until last year when a Windows 10 security update disallowed the use of scripts in Rules. I fixed this by adding the EnableUnsafeClientMailRules key to the Outlook / Security entry in the Registry. Everything worked OK until July 9th 2018. The Rule runs, moves the email to another Outlook folder and quits; but it bypasses the VBA script. There are no error messages displayed, and I can't find any entries in the Windows 10 Event Viewer.

Here's the Rule.
1538007724111.png

Here's the VBA code:
Sub CopyAttachment(myMessage As Outlook.MailItem)

Dim strID As String
Dim objMail As Outlook.MailItem
Dim myAttachments As Attachments
Dim myAttach As Attachment
Dim myBackupFile As String
Dim myFolder As String
Dim mySubj As String

strID = myMessage.EntryID
Set objMail = Application.Session.GetItemFromID(strID)
mySubj = objMail.Subject

If Left(mySubj, 6) = "REPORT" Then Exit Sub 'ignore the report email

Set myAttachments = objMail.Attachments

If InStr("_Br8DB_", mySubj) Then 'this is a production DB backup

If Day(objMail.SentOn) = 1 Then 'this is the first day of the month so save to the Archive
myFolder = "C:\Users\Weller\Dropbox\SIR_Backup_Dan\DB Back\Archive\" & Year(objMail.SentOn) & "\"

For Each myAttach In myAttachments
myBackupFile = myAttach.FileName
myAttach.SaveAsFile myFolder & myBackupFile
Next
Else
myFolder = "C:\Users\Weller\Dropbox\SIR_Backup_Dan\DB Back\" 'save to the daily folder

For Each myAttach In myAttachments
myBackupFile = myAttach.FileName
myAttach.SaveAsFile myFolder & myBackupFile
Next
End If ' if Day 1

Else ' this is a TEST DB backup

myFolder = "C:\Users\Weller\Dropbox\SIR_Backup_Dan\DB Back\Test DB\" 'save to the daily folder

For Each myAttach In myAttachments
myBackupFile = myAttach.FileName
myAttach.SaveAsFile myFolder & myBackupFile
Next
End If ' if day 1

Set objMail = Nothing
Set myAttach = Nothing

End Sub


I have set a VBA breakpoint at the beginning of the script, but it never is triggered. Thus, the script has been skipped.

Thanks for any suggestions on how to address solving this problem.

Thanks.
 
Rather than move the message using the rule, move it in the script. The only action should be run the script - to test this, remove the Move action. Move message macro: https://www.slipstick.com/developer/code-samples/use-vba-move-messages-based-values-fields/


The other option, since you are moving the message to a folder, is to use the rule to move the message and an ItemAdd script to watch the folder and save attachments. ItemAdd sample: https://www.slipstick.com/developer/save-attachments-to-the-hard-drive/#itemadd
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S Unable to remove rule outlook 2010 Using Outlook 0
S using script rule to save attachments on arrival Outlook 2010 Outlook VBA and Custom Forms 9
F Outlook 2010 and Hotmail Using Outlook 1
S Adding a recipient's column to Sent folder in Outlook 2010 Outlook VBA and Custom Forms 1
e_a_g_l_e_p_i Can emails from Gmail be deleted when they are downloaded to Outlook 2010 Using Outlook 1
L Outlook 2010 Outlook 2010 Outlook VBA and Custom Forms 2
C What folders are needed when reinstalling Outlook 2010 Using Outlook 0
e_a_g_l_e_p_i Gmail in Outlook 2010 preview issue Using Outlook 4
e_a_g_l_e_p_i Outlook 2010 Help setting up Gmail account in Outlook 2010 Using Outlook 3
B Outlook 2016 Unable to view images or logos on the outlook 2016 emails the same html code works well when i use outlook 2010 Using Outlook 0
M Outlook 2010 Outlook 2010 with O365 / Exchange Online Using Outlook 0
F Outlook 2010 Outlook 2010 and GMail Using Outlook 0
D Outlook 2007 vs. Outlook 2010 -- ToDo Bar Using Outlook 0
e_a_g_l_e_p_i I think it may be time to upgrade from Outlook 2010 Using Outlook 3
T Why does outlook 2010 convert only some forum notifications to plain text? Using Outlook 0
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
M Outlook 2010 Problem with OutLook 2010 32 bit, after Windows Auto Update Using Outlook 3
M PST import from Outlook 2007 to 2010 - Address Book contacts all in 1 group Using Outlook 4
D Outlook 2010 account setup fails in particular domain Using Outlook 3
B Outlook 2010 is Auto Purging when not configured for that Using Outlook 1
W Outlook 2010 Reading Pane Slows Startup Using Outlook 3
S Outlook 2010 unable to change default font Using Outlook 7
B Outlook 2010 Can not find a certain file in M/S Outlook 2010. Using Outlook 1
Mark Foley Cannot enable add-in in outlook 2010 Using Outlook 0
W Outlook 2010 some sent items marked unread now (was Ok before) Using Outlook 0
RBLampert Updating from Outlook 2010 to Outlook 365 Using Outlook 0
L What are the risks of opening an Outlook 2016 .pst file in Outlook 2010? Using Outlook 4
N Outlook 2010 Flag blocked for Safe Senders List???? Using Outlook 7
Mark Foley Unable to subscribe to published calendar in Outlook 2010 Using Outlook 4
K Maximum Categorize Shortcuts In Outlook 2010? Using Outlook 1
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
RBLampert Outlook 2010 no longer (?) shrinks large images Using Outlook 4
N Outlook 2010 will not send nor receive Using Outlook 4
U Outlook 2010 'freezes' before moving emails Using Outlook 2
P Outlook 2010 trusted emails going to spam folder Using Outlook 18
E Outlook 2010 Subject sort uses Thread-Topic for grouping Using Outlook 2
King Mustard Maximum Categorize shortcuts in Outlook 2010? Using Outlook 1
C Outlook 2010 keeps asking for username and password Using Outlook 1
M Duplicate Primary Mail Accounts outlook 2010 Using Outlook 0
T Compacting Outlook 2010 OST results in old emails being re-sent Using Outlook 6
K Outlook 2010 duplicate download emails 1 inbox 1 PST no updates Using Outlook 3
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
Potty Ash MS Outlook 2010 custom form - validation or formula to request user to check a checkbox Outlook VBA and Custom Forms 16
RBLampert Outlook 2010 sends to/receives from some Gmail addresses but not others Using Outlook 3
e_a_g_l_e_p_i Question about address book in Outlook 2010 Using Outlook 9
e_a_g_l_e_p_i Is there a good third party SPAM filter that intergrates with Outlook 2010 Using Outlook 7
e_a_g_l_e_p_i Another reinstall of Outlook 2010 issue Using Outlook 10
S Outlook 2010 Cannot Open Attachments Using Outlook 14
Justo Horrillo Issue with rules in Outlook 2010 Using Outlook 4
L Upgrade from Outlook 2010-any reason to? Using Outlook 1

Similar threads

Back
Top