Scripting rules - no scripts appear. HELP

  • Thread starter Thread starter ms office worker
  • Start date Start date
M

ms office worker

I tried to program a script to deal with incoming
messages. I opened VBA through outlook, programmed it as
instructed on the page with a Sub, and saved it.

But when I try to use the 'run a script' option, the pop-
up box lists no scripts.

Where are they?
 
Does your procedure look like this:

Public Sub DoIt(MyMessage as MailItem)
' code to do something with MyMessage
End Sub
 
Sue Mosher (author and genius) helpfully responded:
Does your procedure look like this:
Public Sub DoIt(MyMessage as MailItem)
' code to do something with MyMessage
End Sub

I now respond:
Now it does. Thanks (I have no idea what
happened, but adding 'Public" and an item
in the parens made a difference). Note also
that I added the comment after Sue's name--
Sue is not bragging.

But now I'm stuck again. I tried this:

Public Sub SaveAttachments(MyMessage As MailItem)
MyMessage.Attachments.Item(i).SaveAs "c:\Temp\x")
End Sub

But no attachment shows up in my Temp
directory, as it should. But the rule
should have triggered. I tried 3x.
Note for this application I expect
to have only one attachment, so I don't
need a loop. I assume I have not properly
referred to the message, although
I'm at a loss for how to do so. Or maybe
I'm wrong. Any ideas?
 
Your code never sets a value for the variable i. Since you expect only one
attachment, replace i with 1.

Also, the method you want is SaveAsFile, not SaveAs. The object browser is
your friend. Press ALt+F11 to open the VBA environment in Outlook, then
press F2. Switch from <All Libraries> to Outlook to browse all Outlook
objects and their properties, methods, and events.
 
Back
Top