I have the following code that will open up an attachment in in the associated program. I am trying to setup a rule that it will run from a certian email address. The issue is when i choose run this script, it isnt't listed.

Sub OpenAttachmentInNativeApp()
' based on code posted by Sue Mosher
' http://tinyurl.com/684zg4

Dim myShell As Object
Dim MyItem As Outlook.MailItem
Dim myAttachments As Outlook.Attachments
Dim i As Long
Dim Att As String

On Error Resume Next
Select Case TypeName(Application.ActiveWindow)
 Case "Explorer"
     Set MyItem = ActiveExplorer.Selection.Item(1)
 Case "Inspector"
     Set MyItem = ActiveInspector.CurrentItem
 Case Else
End Select
On Error GoTo 0

If MyItem Is Nothing Then
 GoTo ExitProc
 End If

Set myAttachments = MyItem.Attachments
' Windows Script Host Object
Set myShell = CreateObject("WScript.Shell")


If myAttachments.Count > 0 Then
 For i = 1 To myAttachments.Count
     Att = myAttachments.Item(i).DisplayName
     ' delete just in case it exists from before
    On Error Resume Next
     Kill "C:\" & Att
     On Error GoTo 0

    myAttachments.Item(i).SaveAsFile "C:\" & Att
     myShell.Run "C:\" & Att
 Next i
End If

ExitProc:
Set myAttachments = Nothing
Set MyItem = Nothing
Set myShell = Nothing
End Sub
link|improve this question
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.