Run A Script not listed in rules wizard

  • Thread starter Thread starter laavista
  • Start date Start date
L

laavista

I'm using Outlook 2003. I purchased an Outlook VBA book, and it shows
examples of using the rules wizard "run a script". I do not see this option
when I go into rules, and I would really like to use it.

Any suggestions?

Thanks, in advance, for your help.
 
In Rules and Alerts click New Rule
Click 'Start From A Blank Rule' and choose a Step 1 option. Click Next
Select one or more conditions and click 'Next'
Under Select Action you should see an option for 'Run A Script', check it
and click on the 'a script' hyperlink in the bottom window.
Choose the script that you wish to run.
Continue the remainder of the wizard.
 
I went through the steps you outlined multiple times, and there's no "run a
script" rule. I wonder if my company "turned off" this option?

I was hoping to use this as the VBA procedure I wrote results in the Outlook
Security Warning and is useless because of the warnings (my user would have
to click 'yes' 400+ times a month). I thought by using the RunAScript rule
it may prevent the warnings.

Thanks for responding.
 
Are you trying to create a rule for outgoing messages? The "run a script"
action is available only for incoming messages.

If you're getting security prompts with normal Outlook VBA code, using the
"run a script" rule isn't necessarily going to get around that. Maybe your
VBA code simply isn't constructed properly to derive all objects from the
intrinsic Application object. You might also want to tell us the security
state shown on the Help | About Microsoft Outlook dialog.
 
If your script is written within Outlook VBA then it should be possible to
write your code so that the warnings do not appear. Do you have any lines of
code similar to:-

Set objOutlook = New Outlook.Application
or
Set objOutlook = CreateObject("Outlook.Application")

If so then try changing this to:-

Set objOutlook=Outlook

If you then create further objects from this, such as:-

Set objNamespace = Outlook.GetNameSpace("MAPI")
Set objContacts = objNamespace.GetDefaultFolder(olFolderContacts).Items

and so on, you will prevent the security warning from being shown as
'Outlook' is an in-built object that picks up a reference to the currently
running Outlook application.

If you need any further assistance then post your code and I will see what
needs changing.
 
Alan, you do not know how much I appreciate you looking at my code to see if
the security warnings can be eliminated. I REALLY need to get this working
and have spent hours (and hours) trying things, researching, and trying more
things, with no luck. THANK YOU.

The reason I need this-- I have several users who send 400+ emails a month
to customers with attachments. In order for their billing reconciliation to
match, they have to remember to send a copy of these emails WITHOUT the
attachments to the billing personnel who runs a reconciliation procedure to
match emails sent to customers against a database. If the user forgets to
send the email (they reply with different addressees so the attachments are
not sent), then it causes a reconciliation check, an email has to be sent to
the user asking for a copy of the email, the user has to send it and someone
tracks that it's received. My intent: after the user sends the email to
their customer, the rules wizard would automatically move the sent email
(based on words in the subject) to a folder, then the sub procedure would run
sending a reply to the appropriate billing people.

My code:

CODE IS IN “THISOUTLOOK SESSIONâ€

Option Explicit
Dim WithEvents ReplyToItItems As Items

Private Sub Application_Startup()
Dim ns As Outlook.NameSpace

Set ns = Application.GetNamespace("MAPI")
Set ReplyToItItems = ns.Folders.Item("Personal
Folders").Folders.Item("test").Items

End Sub


Sub ReplyToItItems_ItemAdd(ByVal Item As Object)
' when a new item is added to "test folder" it is processed

Dim myReply As MailItem

Set myReply = Item.Reply
With myReply
.To = "(e-mail address removed)"
.Send
End With

End Sub

Private Sub application_quit()
Dim ns As Outlook.NameSpace
Set ReplyToItItems = Nothing
Set ns = Nothing
End Sub

=======
 
Did you check your security state yet? If it says "administrator
controlled," that means that the Exchange administrator is controlling
security and, unless they loosen it for you, you won't be able to run VBA
code without security prompts.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
Your code works perfectly on my stand-alone Outlook. I fear therefore that,
as Ms Mosher has already suggested, that the Outlook security has been
tightened up by your administrators.

Do you have to email this reply to the billing people? If you are running
Exchange server, could the email be copied to a public folder perhaps? This
shouldn't trigger the security prompts. Your code could be easily modified
to do this. Failing that, if you have Visual Studio, could you convert this
code to run via an Outlook Addin?
 
You might have an idea-- to copy it to a public folder. I would have to
figure out how to copy it without the attachments, though. (I'm VERY new to
Outlook VBA). I'll see if I can figure out how to do that.

Alan, THANK YOU, for taking the time to look at my code. It really helped.
I thought perhaps that I coded something incorrectly. REALLY appreciate it.
 
Does this help?

Public Sub SaveACopy(objMailItem As MailItem)
Dim objMailCopy As MailItem
Dim objNamespace As NameSpace
Dim objPublicFolder As MAPIFolder
Dim objAttachment As Attachment

Set objMailCopy = objMailItem.Copy
Set objNamespace = Outlook.GetNamespace("MAPI")
Set objPublicFolder = objNamespace.Folders("Public Folders")
Set objPublicFolder = objPublicFolder.Folders("All Public Folders")
Set objPublicFolder = objPublicFolder.Folders("Insert Your Folder Name")

With objMailCopy
If .Attachments.Count > 0 Then
For Each objAttachment In .Attachments
objAttachment.Delete
Next
End If
objMailCopy.Save
objMailCopy.Move objPublicFolder
End With
Set objMailCopy = Nothing
Set objPublicFolder = Nothing
Set objNamespace = Nothing
End Sub
 
Don't move the copy until you've finished deleting the attachments. Also,
deleting inside a For Each ... Next loop won't work because each deletion
resets the index. Use a down-counting loop instead:

With objMailCopy
count = .Attachments.Count
For i = count to 1 Step -1
Set objAttachment = .Attachments(i)
objAttachment.Delete
Next
End With
objMailCopy.Save
objMailCopy.Move objPublicFolder
 
Back
Top