I had a case recently where a client wanted to send access request emails to an email enabled document library. We encountered the problem of WSS not being able to handle the x-mail header.
A solution was to create a vbscript that fired when an email entered the 'Drop' folder of IIS mailroot and stripped out the problematic header.
Initial testing proved successfull and this has now been implemented.solution
1. copy Smtpreg.vbs into the c:\inetpub\AdminScripts - smtpreg is available to download from MS.
2. create a vbs file from the script below and copy it to the AdminScripts folder (I named mine wss)
<SCRIPT LANGUAGE="VBScript">
Sub ISMTPOnArrival_OnArrival(ByVal iMsg, EventStatus )
if iMsg.Fields("urn:schemas:mailheader:x-mailer") = "Windows SharePoint Services (version 3)" then
iMsg.Fields.Delete("urn:schemas:mailheader:x-mailer")
iMsg.Fields.Update
end if
iMsg.DataSource.Save
EventStatus = 0
End Sub
3. run the following commands to register the script
cd c:\inetpub\adminscripts
cscript smtpreg.vbs /add 1 OnArrival DeleteMsg CDO.SS_SMTPOnArrivalSink "mail from=*"
cscript smtpreg.vbs /setprop 1 OnArrival DeleteMsg Sink ScriptName "c:\Inetpub\AdminScripts\wss.vbs"
4. This will now catch all mail on arrival and remove the offending header.
Where is the script code?
ReplyDeleteReally can you post the script that should be under #2? I'm having the exact same problem and would really like to see how youv'e done this. Thanks!!!
ReplyDeleteI also need this Script code. It would be of great help to us. THX
ReplyDelete<script language="VBScript">
ReplyDeleteSub ISMTPOnArrival_OnArrival(ByVal iMsg, EventStatus )
'Check for Sharepoint x-mailer header
if iMsg.Fields("urn:schemas:mailheader:x-mailer") = "Windows SharePoint Services (version 3)" then
'Delete the offending line
iMsg.Fields.Delete("urn:schemas:mailheader:x-mailer")
'Update the mail header
iMsg.Fields.Update
end if
'Save changes to the mail
iMsg.DataSource.Save
'Continue execution of the next sink
EventStatus = 0
End Sub
</script>
You can find the above code if you view source the page (IE hides it!). I added the comments to try to help.
ReplyDeleteIan
Wonderful! Thanks a lot. I did not know, that it is possible to register an event sink at the SMTP-service.
ReplyDeletethank you, thank you, thank you. I spent a full day troubleshooting this.
ReplyDeleteI tried to implement the above by following the steps: copy smtpreg.vsb from Microsoft, and I created the wss.vsb using the script above however - I am not getting the desired results. X-Mailer: Windows SharePoint Services (version 3) still remains in the .eml file. Is there an additional step outside of running the commands to register the script? Thanks!
ReplyDeleteHi
ReplyDeletethere is no additional step.
Can you post your code on here so I can take a look at it
I am just pasting in this guy to create the wss.vsb script:
ReplyDeleteSub ISMTPOnArrival_OnArrival(ByVal iMsg, EventStatus )
if iMsg.Fields("urn:schemas:mailheader:x-mailer") = "Windows SharePoint Services (version 3)" then
iMsg.Fields.Delete("urn:schemas:mailheader:x-mailer")
iMsg.Fields.Update
end if
iMsg.DataSource.Save
EventStatus = 0
End Sub
And I am getting the smtpreg.vbs script from Microsoft:
http://msdn.microsoft.com/en-us/library/ms528023(v=exchg.10).aspx
My emails appear in the /Drop folder - so nothing on the surface seems out of whack. I just am not able to strip out the X-Mailer header.
Thanks again for the code and the help.
are you saving this as .vbs or .vsb ?
ReplyDeleteIt should be vbs
.vbs - sorry, poor typing in the earlier post. And to clarify this MOSS 2007 with WSS 3, and the most recent cumulative update from Microsoft.
ReplyDeleteNo errors get kicked back while registering the scripts in the command prompt either.
Thanks
Hi...and the name of your vbs file?
ReplyDeleteSame thing as posted above: Smtpreg.vbs and wss.vbs
ReplyDeleteHow would you change this to work with SharePoint 2010? I assume the "Windows SharePoint Services (version3)" line needs to change, but I'm not sure what to change it to.
ReplyDeleteHow do you make it so you can see the messages in transit to know what the fields and data look like?
Toby Hosterman
toby@natpain.com
Hi Toby
ReplyDeleteYou will have to capture one of the emails in the c:\\inetpub\mailroot\drop\ folder.
Open it up with notepad and see what the mailheader says.
Nevermind, I got it working by tweaking wss.vbs a little as follows, hopefully making it SharePoint version independent:
ReplyDelete<_SCRIPT LANGUAGE="VBScript">
Sub ISMTPOnArrival_OnArrival(ByVal iMsg, EventStatus )
if instr(iMsg.Fields("urn:schemas:mailheader:x-mailer"),"SharePoint") > 1 then
iMsg.Fields.Delete("urn:schemas:mailheader:x-mailer")
iMsg.Fields.Update
end if
iMsg.DataSource.Save
EventStatus = 0
End Sub
Toby Hosterman
toby@natpain.com
great stuff.....glad the script helped a little
ReplyDeleteAre there any services that must be restarted for this to take affect?
ReplyDeletenot that I'm aware of
ReplyDeleteDoes this solution require MS Exchange server to be running or will it work with the SMTP Server that comes with IIS 6?
ReplyDeletethe script is for the local smtp service
ReplyDeleteThank you for this -- worked great!!!
ReplyDeleteTrying to do this in our new SharePoint 2013 environment but the smptreg script keeps failing...getting a Permission Denied even with an elevated cmd screen. Also says "have you registered your sink COM class on this machine" which I haven't been able to find anything on.....
ReplyDeleteGreat article ...Thanks for your great information, the contents are quiet interesting.
ReplyDeleteSharePoint Training
SharePoint Online Training
Use the article below if you get access denied:
ReplyDeletehttps://blog.vamsoft.com/2009/12/12/smtp-event-sinks-under-windows-server-2008-r2/