Solved

Fire a script when a mailbox receives a message.

Posted on 2006-11-06
8
243 Views
Last Modified: 2010-03-06
I'm having problems with a service running on my Exchange Server.  I'd like to be able to have a batch file run when an email is received in a specific mailbox.  When using the Rules Wizard in Outlook it appears as though I could run a script, but it would only work if I had a machine running, Outlook open.  I need something that will run server side.  I've heard about "Event Scripting" but can't seem to find any good write ups with examples.  Can anyone point me in the right direction?
0
Comment
Question by:nummagumma2
[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
  • 5
  • 3
8 Comments
 
LVL 23

Expert Comment

by:Stacy Spear
ID: 17882393
Event Sinks - http://www.microsoft.com/downloads/details.aspx?familyid=0CD7F344-CAD6-416E-9BC1-0D7C214E1D0B&displaylang=en

Are the way to go. Can be a variety of languages and can be used for all sorts of things.
0
 
LVL 23

Expert Comment

by:Stacy Spear
ID: 17882405
I believe somewhere on MSDN (if not in the download) there is an example with code of exactly what you want to do. Off today, so my workstation with the download on it is not available.
0
 
LVL 1

Author Comment

by:nummagumma2
ID: 17882771
darkstar - thanks for posting.  I've read the doc you sent and see that the method is what I want - unfortunately there's no sample code in the download (or anywhere else on MSDN that I can find) that I can tweak to do what I want.  I'm still looking for a good example of a sink that would permit some kind of batch file to be executed...
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 23

Expert Comment

by:Stacy Spear
ID: 17882990
Code example - outgoing (easily modifiable to incoming) http://support.microsoft.com/kb/317680 

On arrival code example - http://support.microsoft.com/kb/313404
0
 
LVL 23

Expert Comment

by:Stacy Spear
ID: 17883013
Posted too quick. I thought it was on MSDN, but it seems as if all is on support.microsoft. Here is a good bit here.

http://www.google.com/search?num=20&hl=en&lr=lang_en%7Clang_de&newwindow=1&safe=off&c2coff=1&rls=GGGL%2CGGGL%3A2006-17%2CGGGL%3Aen&q=smtp+event+sinks+vb+code+incoming+messages&btnG=Search&lr=lang_en%7Clang_de

Glenn's example of using MS sinks (his stuff is great, plus he help write the app) http://gsexdev.blogspot.com/2005/05/c-catchall-onarrival-event-sink.html
0
 
LVL 1

Author Comment

by:nummagumma2
ID: 17883204
Thanks darkstar.  I found those.  I've used the one for outgoing disclaimer message in the past.  Unfortunately, not being a programmer, I'm not savvy enough to tweak either of them to fire when mail is received on only 1 email address, nor am I clear where to tweak to make it so that the code would call my existing batch file... (or how to incorporate my batch into the sink).

The logic is simple enough to me, just not how to code it.

if message arrives on specialaddress@domain.com then fire batch file.

I suppose it would be best if the message had a specific word or phrase in the subject to limit the small possibility of abuse by a spammer...
0
 
LVL 23

Accepted Solution

by:
Stacy Spear earned 500 total points
ID: 17883595
Perhaps something along the lines of the following:

<SCRIPT LANGUAGE="VBScript">

Sub IEventIsCacheable_IsCacheable()
      'To implement the interface, and return S_OK implicitly
End Sub

Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
      Dim envFlds
      Dim colAttachs
      Dim iFound
      Set envFlds = Msg.EnvelopeFields

      If Msg.To = "specialaddress@domain.com" and Msg.Subject = "specialsubject" Then
            'perform batch file stuff here (VBS only I think)
            'or maybe call filename.batch
      Else
            'do nothing
      End If
      

End Sub

</SCRIPT>
0
 
LVL 1

Author Comment

by:nummagumma2
ID: 18025035
Untested, but I'll assume it works.... no time to test and want to award points for effort.

Thanks darkstar.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
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…
Suggested Courses

627 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