have problems with using IIS Admin objects to manage IIS programatically
in VB .NET.

I adopted VB Script sample codes from

and managed to get the following working in VB 6 and VB Script to change
the properties in my Virtual SMTP Server on IIS 5.0 (build 2195) on Windows
2000 Worksation with SP2:
Dim objIIsSMTP
Dim objIPSecurity

Set objIIsSMTP = GetObject("IIS://machinename/SMTPSVC/1")

objIIsSMTP.HopCount = 3

Set objIPSecurity = objIIsSMTP.IPSecurity
objIPSecurity.GrantByDefault = False

objIIsSMTP.IPSecurity = objIPSecurity


However, a similar piece of code in VB .NET does work. It is:
'Dimmed this as Object, because can't find any components which
'defines IIsSMTP
Dim objIIsSMTP As Object
'Added reference from %systemroot%\system32\adsiis.dll
'to use IPSecurity
Dim objIPSecurity as IISOle.IPSecurity
objIIsSMTP = GetObject("IIS://machinename/SMTPSVC/1")

'The following line always work
objIIsSMTP.HopCount = 3
objIPSecurity = objIIsSMTP.IPSecurity
objIPSecurity.GrantByDefault = False

' The following line causes System.ArgumentException to be thrown
objIIsSMTP.IPSecurity = objIPSecurity
Catch ex As Exception
End Try


I get the following exception on the line objIISSMTP.IPSecurity = objIPSecurity,
which my .Net code catches and writes to MsgBox and Console window:
System.ArgumentException: The parameter is incorrect.
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet(Object
o, Type& objType, String name, Object[] args, String[] paramnames, Boolean
OptimisticSet, CallType UseCallType)
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateSet(Object o,
Type objType, String name, Object[] args, String[] paramnames)
at SMTPApiTest.Form1.cmdGetObj_Click(Object sender, EventArgs e) in C:\dev\SMTPApiTest\Form1.vb:line

It apperas that there is some sort of late binding problem with objIIsSMTP.

I have also refered to the IISAdmin Object overview at http://search.microsoft.com/gomsuri....p/aogu0t6f.asp

As such, I tried
objIIsSMTP.put("IPSecurity",objIPSecurity) instead of
objIIsSMTP.IPSecurity = objIPSecurity

This does not throws any exception. Unfortunately, it does not set any IPSecurity
either (as I check under my IIS Manager->Virtual SMTP Server->Properties->Access

The following line do appear to reflect the settings of my IIS Virtual SMTP
Server. This is confirmed by my earlier experimentations using codes similar
to those found at http://msdn.microsoft.com/library/de...p/aore0hro.asp
to list IP addresses which were granted access to the Virtual SMTP.
objIPSecurity = objIIsSMTP.IPSecurity

I would appreciate if you could advise of what DLL I need to declare objIIsSMTP
using Early Bind Time &/or other techniques to prevent the System.ArgumentException
being throw whilst setting IPSecurity property.

There is only file on my PC containing the string IIsSMTP. It is %systemroot%\system32\INETSRV\SMTPSVC.DLL
.. Unfortunately, it does not appear to be a valid DLL or .NET Framework
that Visual Studio could use in Adding reference or Object browser.