SMTP.WS Microsite - Microsoft SMTP Service

Welcome to SMTP.WS

“Providing information about Microsoft SMTP Service”

Relay Restrictions and SMTP service, IISOLE.dll reference

This is one of *those* posts I refer to from time to time.  There have been a few posts on http://Forums.iis.net regarding how to manage relay restrictions in SMTP service.   I've used the IISOLE.dll against an IIS 6 server with no issues.  I've not tested on IIS 7, so mileage may vary.  Make sure to install the IIS 6.0 compat modules and test on a non-production box.   If nothing else, download a trial version and create an instance using vmware, hyper-V or Virtual PC.

Here is one way using code.  You'll need to get the IISOLE.dll which is the COM interface.

1) Download VB 2008 express (search for this link) 

2) Go to codeplex and download this project, extract the OLEDLL.dll 
http://www.codeplex.com/SLK

3) Make a project in VB2008 express

4) Make a reference to the IISOLE.dll

5) Paste this code into your main and run

Dim objValue As New DirectoryEntry("IIS://localhost/smtpsvc/1")
Dim objIPSec As IISOle.IISIPSecurity = objValue.Properties("RelayIpList").Value
objIPSec.IPGrant = New Object() {"192.168.55.50", "192.168.22.20"}
objValue.Properties("RelayIpList").Value = objIPSec
objValue.CommitChanges()

Here is a reference of the entire IISOLE.dll. 
http://www.webtropy.com/articles/art14-2.asp?Interop=IISOle

 Here is the additional post.

http://forums.iis.net/p/1148477/1865759.aspx

Happy SMTP

Steve Schofield
Microsoft MVP - IIS