A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Run A Script not listed in rules wizard



 
 
Thread Tools Search this Thread Display Modes
  #11  
Old July 9th 09, 02:15 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default STILL IS NOT AVAILABLE... Run A Script not listed in rules wiz

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

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Alan Moseley" wrote in message
...
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
--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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.

"Alan Moseley" wrote:

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?

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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 = "
.Send
End With

End Sub

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

=======

"Alan Moseley" wrote:

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).It ems

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 Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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.



"Alan Moseley" wrote:

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.

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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.



Ads
  #12  
Old July 9th 09, 05:52 PM posted to microsoft.public.outlook.program_vba
laavista
external usenet poster
 
Posts: 15
Default STILL IS NOT AVAILABLE... Run A Script not listed in rules wiz

Alan, this was VERY helpful!! Again, thank you so much. You have saved me
hours.



"Alan Moseley" wrote:

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
--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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.

"Alan Moseley" wrote:

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?

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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 = "
.Send
End With

End Sub

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

=======

"Alan Moseley" wrote:

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).It ems

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 Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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.



"Alan Moseley" wrote:

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.

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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.

  #13  
Old July 9th 09, 05:53 PM posted to microsoft.public.outlook.program_vba
laavista
external usenet poster
 
Posts: 15
Default STILL IS NOT AVAILABLE... Run A Script not listed in rules wiz

THANK YOU for your help with this!!! I appreciate your time!

"Sue Mosher [MVP]" wrote:

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

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Alan Moseley" wrote in message
...
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
--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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.

"Alan Moseley" wrote:

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?

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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 = "
.Send
End With

End Sub

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

=======

"Alan Moseley" wrote:

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).It ems

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 Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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.



"Alan Moseley" wrote:

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.

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"laavista" wrote:

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.




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rules Wizard Script Henry Stockbridge Outlook and VBA 2 August 29th 08 08:01 PM
"Run a Script" does not appear as an Action in the Rules Wizard Bob Miller Outlook - General Queries 1 November 4th 07 10:19 PM
Fax numbers no longer listed in send fax wizard addresses. Brian Outlook - Using Contacts 8 July 30th 07 03:44 AM
Help Running a script in Rules Wizard to save attachments Murphybp2 Outlook and VBA 1 May 1st 07 10:04 PM
Custom Rule or Script for Rules Wizard Rick Outlook and VBA 0 April 13th 07 09:10 PM


All times are GMT +1. The time now is 02:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright 2004-2025 Outlook Banter.
The comments are property of their posters.