J
John
Hi all.
I'm having a problem, I have just written my first VBA macro for
Outlook and have tried to attach it to a rule. The macro lives in
ThisOutlookSession and is as follows:
Sub SaveAttach()
Dim myApplication As Application
Dim myNameSpace As NameSpace
Dim myMessage As Object
Dim myAttachment As Outlook.Attachment
Set myApplication = New Outlook.Application
Set myNameSpace = myApplication.GetNamespace("MAPI")
Set MyFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
For Each myMessage In MyFolder.Items
With myMessage
If .SenderName = "(e-mail address removed)" Then
If .Attachments.Count <> 0 Then
myMessage.Attachments.Item(1).SaveAsFile "G:\Webserver\" &
..Attachments.Item(1).DisplayName
' .Delete
End If
End If
End With
Next
End Sub
That's all that's in there. If I run the VBA code and step through,
everything seems to work correctly. But then when I go to the rules
dialog and select the rule 'Apply this rule after the message arrives
from (e-mail address removed) and on this machine only run _a script_' I click
on _a script_ and nothing show up in the Select Script Dialog Box. I
would expect something like Project1.ThisOutlookSession.SaveAttach(),
but it's not there. Any ideas would be greatly appreciated.
Thanks.
John
johnnylooper(at)yahoo.com
I'm having a problem, I have just written my first VBA macro for
Outlook and have tried to attach it to a rule. The macro lives in
ThisOutlookSession and is as follows:
Sub SaveAttach()
Dim myApplication As Application
Dim myNameSpace As NameSpace
Dim myMessage As Object
Dim myAttachment As Outlook.Attachment
Set myApplication = New Outlook.Application
Set myNameSpace = myApplication.GetNamespace("MAPI")
Set MyFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
For Each myMessage In MyFolder.Items
With myMessage
If .SenderName = "(e-mail address removed)" Then
If .Attachments.Count <> 0 Then
myMessage.Attachments.Item(1).SaveAsFile "G:\Webserver\" &
..Attachments.Item(1).DisplayName
' .Delete
End If
End If
End With
Next
End Sub
That's all that's in there. If I run the VBA code and step through,
everything seems to work correctly. But then when I go to the rules
dialog and select the rule 'Apply this rule after the message arrives
from (e-mail address removed) and on this machine only run _a script_' I click
on _a script_ and nothing show up in the Select Script Dialog Box. I
would expect something like Project1.ThisOutlookSession.SaveAttach(),
but it's not there. Any ideas would be greatly appreciated.
Thanks.
John
johnnylooper(at)yahoo.com