PDA

View Full Version : Script not running automatically anymore



110kiley
03-13-2013, 08:58 AM
Our company recently converted us all to GMAIL... boo... so I setup IMAP to continue to use outlook.

I've had a rule, in which it moves the email to a folder and also runs a script.

After this conversion, the rule runs and moves the email, but does not run the script. HOWEVER, if I move the back into the main inbox and 'run rules now', the entire rule runs fine. Not sure it helps to post the script, but it's below.

Any thoughts? Thanks!

Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim strFile As String
Dim strFolderpath As String
Dim strFileName As String
Dim strSubject As String



strSubject = itm.subject
If UCase(strSubject) Like "*BEACON*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Beacon\"
ElseIf UCase(strSubject) Like "*TEA*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\TEA\"
ElseIf UCase(strSubject) Like "*POWELL*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Powell\"
ElseIf UCase(strSubject) Like "*MITCHELL*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Mitchell\"
ElseIf UCase(strSubject) Like "*NORTH*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\North\"
ElseIf UCase(strSubject) Like "*CORKER*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Corker\"
ElseIf UCase(strSubject) Like "*RAAMPAC*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Raampac\"
ElseIf UCase(strSubject) Like "*COBB*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Cobb\"
ElseIf UCase(strSubject) Like "*BARNES*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Barnes\"
ElseIf UCase(strSubject) Like "*DICKERSON*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Dickerson\"
ElseIf UCase(strSubject) Like "*HOUSEMAJPAC*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\HouseMajPac\"
ElseIf UCase(strSubject) Like "*JERNIGAN*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Jernigan\"
ElseIf UCase(strSubject) Like "*GREEN*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Green\"
ElseIf UCase(strSubject) Like "*STEWART*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Stewart\"
ElseIf UCase(strSubject) Like "*TNREPUBCAUCUS*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\TNREPUBCAUCUS\"
ElseIf UCase(strSubject) Like "*HENSLEY*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Hensley\"
ElseIf UCase(strSubject) Like "*WILLIAMSON*" Then
strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\Williamson\"
Else: strFolderpath = "C:\Users\kmurphy\Documents\Dropbox\Public File\xPolitical\"
End If
strFileName = strSubject & ".pdf"
strFile = strFolderpath & strFileName

For Each objAtt In itm.Attachments

objAtt.SaveAsFile strFile

Set objAtt = Nothing

Next

End Sub

skatonni
04-12-2013, 07:19 AM
Run a script rules are notoriously unreliable.

Try ItemAdd or NewMailEx described here http://www.outlookcode.com/article.aspx?id=62.

The code runs after the item gets to the Inbox.