Solved

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

Posted on 2004-04-07
16
457 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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Resolve DNS query failed errors for Exchange
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
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…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

746 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

16 Experts available now in Live!

Get 1:1 Help Now