Solved

How to set a rule to run a macro after seeing specific word in the subject Box

Posted on 2004-04-07
16
462 Views
Last Modified: 2010-04-08
I'm facing a problem  to set up a rule to run a macro

i've gone to Rule Wizard
 And Started creating a new rule
Checked the Box "with specific words in the Subject" and specified the Specific word

then clicked next

Now I got these options nearer to my task

Start Application
run a script
Perform a cutom action

But from these three I could not mention the macro which I've already created

Can You please help me
0
Comment
Question by:LakshmanaRavula
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 2
  • +1
16 Comments
 

Author Comment

by:LakshmanaRavula
ID: 10775044
Can any body respond immedietly
0
 
LVL 18

Expert Comment

by:Karen Falandays
ID: 10776048
Ravula, where is the macro that you have created? Which version of Outlook are you using?
Karen
0
 

Author Comment

by:LakshmanaRavula
ID: 10776237
Thank You karen for your immediate response

I'm using Outlook 2002 and I have to run a programme to update my DB based on the mail received. So I have stored a macro in the Tools -  Macro

This Question is in continuation with my previous question posted in

http://www.experts-exchange.com/Applications/MS_Office/Outlook/Q_20945733.html

Thank You
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:LakshmanaRavula
ID: 10778587
Karen,
I'm waiting for your help
0
 
LVL 18

Expert Comment

by:Karen Falandays
ID: 10779016
I'm sorry Ravula, I do not do code. Let's see if we can get another expert on board.
Karen

0
 

Author Comment

by:LakshmanaRavula
ID: 10779211
can you help me to set a rule to fire a macro in Outlook when it finds a specific word in subject area
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10782197
I may have fed you some duff info, apologies for that

Ive made a comment in your previous post, if your happy with that then I suggest you close this question

0
 
LVL 13

Expert Comment

by:stefri
ID: 10786273
May be can you try this
olInboxItems_ItemAdd will be fired for any incoming mails
The subject is tested against the word you wanted to run your macro


Option Explicit
Dim objNS As NameSpace
Private WithEvents olInboxItems As Items

Private Sub Application_Startup()
  Set objNS = Application.GetNamespace("MAPI")
  Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Application_Quit()
  Set olInboxItems = Nothing
  Set objNS = Nothing
End Sub

Private Sub olInboxItems_ItemAdd(ByVal Item As Object)


  Dim mySubject as String
  mySubject = "to be fired by the rule" ' MUST be in lowercase as Item.subject will be converted to lcase before comparison

  On Error Resume Next
  If Item.Class = olMail Then
      if len(item.subject) > 0 then
      if instr(1,lcase(item.subject),mySubject,1) <> 0 then
                     'INSERT YOUR CODE HERE
      end if
     end if
  End If
End Sub
Hope this helps
Stefri
0
 

Author Comment

by:LakshmanaRavula
ID: 10786367
Stefri My problem is whare to add this code
0
 
LVL 13

Accepted Solution

by:
stefri earned 500 total points
ID: 10786419
Which code? Mine or yours?
Mine:
Alt F11 to open VBA Editor
On the left pane, double click this OutlookSession
Cut an past my code

You said you have written a macro: where is it? In OL or somewhere else?

Stefri
0
 

Author Comment

by:LakshmanaRavula
ID: 10786420
Stefri Can you make it little Clear

I have pasted this code in TOOLS | Macro | Visual Basic editor (Alt F11)

And I just replaced your " 'INSERT YOUR CODE HERE" with a message box and sent some mails with subject containing "to be fired by the rule"

saved and restarte and tried again But I could not get the message box
0
 
LVL 13

Expert Comment

by:stefri
ID: 10786438
What about the Security settings?

Tools/Macro/Security
Set to medium
Close OL

When starting OL, accept the macro to be fired

Stefri
0
 
LVL 13

Expert Comment

by:stefri
ID: 10786492
Otherwise, to run a script from the rule wizzard as you planned to do:

replace the code I provided you by
Option Explicit
Sub itemsAdded(Item As Outlook.MailItem) ' THIS IS THE TRICKY PART


  Dim mySubject As String
  mySubject = "to be fired by the rule" ' MUST be in lowercase as Item.subject will be converted to lcase before comparison

  On Error Resume Next
  If Item.Class = olMail Then
      If Len(Item.Subject) > 0 Then
             If InStr(1, LCase(Item.Subject), mySubject, 1) <> 0 Then
                     'INSERT YOUR CODE HERE
             End If
     End If
  End If
End Sub
Stefri
see: http://support.microsoft.com/?kbid=306108 5I had it in French, I hope you'll get it in English
0
 

Author Comment

by:LakshmanaRavula
ID: 10786497
Ok Stefri Now I under stood Now it is firing
Thank You

can you participate in my other Question just related to this
0
 
LVL 13

Expert Comment

by:stefri
ID: 10786549
Is it working?
If it is using Run a script, I just posted 1 minute ago how to transform the code to be used with Rules Wizzard

Do you want me to put the answer in the alternate thread? If yes, I will jump to postion three for the year in Outlook area

Stefri
0
 

Author Comment

by:LakshmanaRavula
ID: 10786592
Yes the code is working and firing the message

And I just replaced your " 'INSERT YOUR CODE HERE" with a message box and sent some mails with subject containing "to be fired by the rule"

And finally as you said I pasted this in On the left pane, double click this OutlookSession

My other Question is

http://www.experts-exchange.com/Applications/MS_Office/Outlook/Q_20945733.html


Please follow and try to help me
Thank You
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Email Send REcieve Problem on TMG 2010 6 61
outlook error send and receive 15 97
Outlook 2013 Contacts - comma-separated-field 20 34
Exchange 2007 6 21
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question