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