Solved

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

Posted on 2004-04-07
16
460 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
  • 8
  • 5
  • 2
  • +1
16 Comments
 

Author Comment

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

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
 

Author Comment

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

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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now