Google
Search WWW Search msexchangetips.blogspot.com

Monday, August 21, 2006

Exchange: Forwarding Copy of User's Email or Public Folder to Another Account Via Event Sink

Summary:

Exchange offers Journaling which allows you to designate a mailbox to receive all emails sent and received from a particular store that you designate. However, Exchange does not give you the granularity to journal only one mailbox. In order to achieve this you will need to install a custom event sink provided below. Before I delve into the implementation of the event sink. I'll go over what event sinks are what they do.

Event sinks are basically a sub-routine that is fired at specific points in the message flow such as during transport. Most event sinks fire just before the message categorizer and right after. However, there are also sinks that run during message transfer. Many Exchange aware AV products register event sinks within Exchange. For example, before a message is sent to the categorizer, it is sent to the pre-submission queue where it is scanned for viruses or verified against the GAL.

Registering The Per User Journaling Event Sink. This event sink provided will forward a copy of all messages sent to your designated recipient to another mailbox such as your admin.



Download the files below (google)
1. SMTPReg.vbs
2. smtpjrnl.vbs


1. Create a directory on your C: drive called Journal. (Or anywhere you wish)

2. You will need the SMTPReg.vbs. Although I downloaded the Exchange SDK, this file was not included. However, I was able to locate it here. In the link, you will need to copy all the code in the [smtpreg.vbs Event Management Script] and paste it into notepad. Name this file as smtpreg.vbs and paste it into your C:\Journal directory.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/smtpevt/html/6b7a017e-981e-45a1-8690-17ff26682bc7.asp

3. Open notepad and copy the entire contents below and name this file smtpjrnl.vbs


script language="VBScript"

Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus ) on error resume next Dim RecpList recplist = LCase(Msg.EnvelopeFields("http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist")) recplist = recplist & "SMTP:admin@yourdomain.com;" Msg.EnvelopeFields("http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist") = recplist Msg.EnvelopeFields.update

End Sub

/script


4. In the recplist = recplist & "SMTP:admin@yourdomain.com;"
Enter the SMTP address in which you would like all of the forwarded emails to go to. (Include the quotes)

5. Open command prompt. Go to Start --> Run, type cmd, ok
CD CD journal

cscript smtpreg.vbs /add 1 onarrival smtpjrnl CDO.SS_SMTPOnArrivalSink "Rcpt to=internaluser@yourdomain.com"

(Note: This will forward any emails sent to your internal user or public folder SMTP address here to the SMTP address you specified in step 4)

6. If you wish to customize it so that mail from a particular domain say anything from hotmail sent to internaluser@yourdomain gets forwarded to admin@yourdomain.com, change the code in step 5 to: "Rcpt to:internaluser@yourdomain mail from:user@hotmail.com")

Now you will need to associate smtpreg.vbs to your smtpjrnl.vbs sinkcscript. Type the following command below in your command prompt.

smtpreg.vbs /setprop 1 onarrival smtpjrnl Sink ScriptName c:\journal\smtpjrnl.vbs

Note: If you receive Binding Dispaly Name Specified: smtpjrnlFailed to find binding with dispaly name: smtpjrnl, re-enter the command below. Note the smtpjrnl.vbs in the first line. It appears that there is a bug, sometimes it registers with out the .vbs other times it doesn't.

cscript smtpreg.vbs /setprop 1 onarrival smtpjrnl.vbs Sink ScriptName c:\journal\smtpjrnl.vbs

7. Test by emailing to internaluser@domain.com from an outside account. It should be forwarded to admin@yourdomain.com. There is a limitation to this. When sending internally, if the internaluser@domain.com and admin@yourdomain.com exists on the same Exchange server, it will not work even with public folders. This is by design. You can circumvent this if you use a frontend server that handles all your inbound mail and forwards to your backend Exchange servers.

8. To remove the event sink. Go to your command prompt. From your C:\Journal directory type the following command:

cscript smtpreg.vbs /remove 1 onarrival smtpjrnl

1 = SMTP Virtual Service
onarrival = sink class
smtpjrnl = sink name


James Chong
MCSE M+, S+, MCTS, Security+
msexchangetips.blogspot.com


How useful was this article? Want to see a tip not listed? Please leave a comment.

18 Comments:

Anonymous Anonymous said...

This is great... but in Step 6 you say: change the code in step 5 to: "Rcpt to:internaluser@yourdomain mail from:user@hotmail.com")

How do I do ANY user... i.e., what's the wildcard value I can use in from:user@hotmail.com for it to end up being *@hotmail.com? What's the full context for replacement? Is it Rcpt from:*@hotmail.com?

9:28 AM  
Blogger jamestechman said...

What are you trying to do? If you want it so that if your internal users send to hotmail it gets forwarded to your admin put

cscript smtpreg.vbs /add 1 onarrival smtpjrnl CDO.SS_SMTPOnArrivalSink "mail from=*@hotmail.com"

Sorry for the typo, I will fix it in the blog!

6:31 PM  
Blogger Unknown said...

I'm in the same boat as Chris. I'm looking to send a copy to a public folder (smtp address is publicfolder@mydomain.com), but I want this rule set up so that if it is sent to anybody and everybody @mydomain.com, originating from anybody and everybody @outsidecompany.com, this rule will be applied. For instance, (anyone)@outsidecompany.com sends an email to (anyone)@mydomain.com, I want a copy sent to publicfolder@mydomain.com...

I hope I said that right...

9:15 AM  
Blogger Mark Harrison said...

Hi Guys,

I have to do a similar thing here where I need to add a diclaimer using VB Script to the end of any external emails. I'm comfortable with using the smtpreg.vbs file (although I didn't get it in ths SDK!). Can someone run through how I can add the same disclaimer text to more than one domain, all are controlled by the same exchange server (if at all).

I have something like this

cscript smtpreg.vbs /add 1 onarrival SMTPScriptingHost CDO.SS_SMTPOnArrivalSink "mail from=*@domain1.com"

Can I add this:

cscript smtpreg.vbs /add 1 onarrival SMTPScriptingHost CDO.SS_SMTPOnArrivalSink "mail from=*@domain1.com,*@domain2.com"

???

Thanks in advance

Mark

1:49 AM  
Anonymous Anonymous said...

Hi James,

I am in a bit of a jam and I need to strip off copies of email messages and forward to a specific user in a IIS SMTP server (no exchange). I know this is an old blog, but could you tell me if this would work with IIS SMTP?

12:43 PM  
Anonymous Anonymous said...

replica handbags , the prestigious fashion house came up with a new purse, named Sunset Boulevard. replica handbags is the ideal accessory for a special occasion. Coated in embossed Monogram Vernis patent leather, replica bags presents us a shiny and brilliant handbag. Besides designer replica handbags features tone on tone leather trimmings and textile and calf leather lining.

5:20 PM  
Anonymous Women Leather Blazers said...

Great post. I really like it. Keep it up.

Buy Leather Jackets,
Leather Skirts

5:01 AM  
Blogger Simple Luxury said...

Burberry Outlet Store Online
Handbags Outlet Store Online
Louis Vuitton Handbags Sale

www.burberry-outlets.org
www.prada-outlet.org
www.bag-louis-vuitton.com

7:34 AM  
Anonymous Women leather blazer said...

nice post love itWomens Leather Skirts

10:26 PM  
Blogger oakleyses said...

louis vuitton outlet, oakley sunglasses, michael kors handbags, cheap jordans, prada handbags, uggs outlet, michael kors outlet, oakley sunglasses, uggs on sale, ray ban sunglasses, burberry outlet, tiffany jewelry, uggs on sale, kate spade, gucci handbags, ray ban sunglasses, prada outlet, longchamp outlet, louboutin uk, burberry factory outlet, tory burch outlet, nike air max, tiffany jewelry, christian louboutin, louboutin shoes, oakley sunglasses, cheap oakley sunglasses, chanel handbags, michael kors outlet store, louis vuitton outlet, nike outlet, ralph lauren polo, louis vuitton, christian louboutin, michael kors outlet online, longchamp outlet, uggs outlet, michael kors outlet online, nike air max, longchamp bags, replica watches, ralph lauren outlet, oakley sunglasses, ray ban sunglasses, louis vuitton outlet online, nike free, michael kors

6:30 PM  
Blogger oakleyses said...

converse shoes outlet, salvatore ferragamo, timberland boots, softball bats, herve leger, ray ban, hollister, louboutin, gucci, nike roshe run, iphone cases, beats by dre, mcm handbags, oakley, p90x workout, insanity workout, wedding dresses, abercrombie and fitch, abercrombie, nike air max, mac cosmetics, babyliss pro, valentino shoes, bottega veneta, mont blanc, converse, jimmy choo outlet, hollister clothing, nike air max, north face outlet, new balance shoes, north face outlet, instyler ionic styler, soccer shoes, lululemon outlet, asics running shoes, ghd hair, giuseppe zanotti, soccer jerseys, nfl jerseys, longchamp uk, reebok outlet, nike air huarache, chi flat iron, hermes handbags, vans outlet, polo ralph lauren, celine handbags, nike trainers uk, vans scarpe

6:33 PM  
Blogger oakleyses said...

toms shoes, supra shoes, montre pas cher, ugg uk, juicy couture outlet, moncler, lancel, michael kors outlet online, ugg pas cher, michael kors handbags, barbour, doke & gabbana, michael kors outlet, coach outlet, louis vuitton uk, canada goose jackets, pandora charms, moncler, ugg,ugg australia,ugg italia, links of london uk, moncler jackets, hollister, juicy couture outlet, canada goose outlet, swarovski uk, pandora jewelry, canada goose pas cher, canada goose outlet, marc jacobs, moncler pas cher, thomas sabo uk, swarovski jewelry, karen millen uk, louis vuitton, moncler, moncler uk, sac louis vuitton, canada goose, moncler outlet, louis vuitton, canada goose, wedding dresses uk, ugg,uggs,uggs canada, canada goose uk, sac louis vuitton, moncler, replica watches, barbour jackets uk, bottes ugg pas cher, canada goose jackets

6:34 PM  
Blogger Unknown said...

saics running shoes
jordan 4
oakley sunglasses
michael kors handbags
michael kors uk
michael kors uk
hugo boss sale
colts jerseys
kate spade outlet
49ers jersey
20170813

3:07 AM  
Blogger Unknown said...

www11.20


kate spade outlet
mbt shoes
christian louboutin
coach outlet online
michael kors outlet
true religion jeans outlet
champion sportswear
ralph lauren polo
pandora charms
off white outlet



11:08 PM  
Blogger jjjjjjjjjjjjj said...

nike polo
irving shoes
goyard handbags
goyard bags
adidas yeezy
curry 5
air max 2018
zx flux
adidas ultra boost
air max 270

10:58 PM  
Blogger yanmaneee said...

supreme
kyrie 6 shoes
converse
lebron shoes
lebron 17
longchamp
golden goose sneakers
moncler
vapormax
golden goose

12:45 AM  
Anonymous Anonymous said...

Thanks for this post.
You read About Us in a different post.

9:00 AM  
Anonymous Anonymous said...

Most times, i feel like it's a blessing to get the latest Free browsing solution daily on my phone.

9:01 AM  

Post a Comment

<< Home

xml:lang="en" lang="en"> MS Exchange Tips: Exchange: Forwarding Copy of User's Email or Public Folder to Another Account Via Event Sink