CourtneySmith
Wed Dec 19 15:10:01 CST 2007
Hi Sofia! I'm and Exchange Admin and you cannot find the server
automatically. There are may factors that play into this and there may be DNS
rules that play a part in it as well. In fact, we created an MX Record in DNS
called "mailrelay" so that the developers can always use that to send email.
It will always find an SMTP server. You may want to talk to your Exchange
Admin to see if you have something like that or to see about getting that
setup in your organization.
--
Thank you!
Courtney
"Jeffery Hicks [MVP]" wrote:
> It might be possible to query the AD configuration to find the Exchanger
> server setup for Internet routing, but it still might be configured to not
> relay your message. You need to talk with an Exchange admin. Your company
> may also have edge network devices that will only accept SMTP traffic from a
> specific IP. Given the number of Exchange servers I would expect your
> company to have something like this in place. I don't think you can do this
> automatically and expect it to work.
>
> --
> Jeffery Hicks
> Microsoft PowerShell MVP
>
http://www.scriptinganswers.com
>
http://www.powershellcommunity.org
>
> Now Available: WSH and VBScript Core: TFM
> Coming Soon: Windows PowerShell: TFM 2nd Ed.
>
> "Sofia Engvall" <@> wrote in message
> news:OTzq8GrNIHA.2268@TK2MSFTNGP02.phx.gbl...
> > What I'm trying to do is to find the right server automatically. Is this
> > not possible? Are there no server roles to check or something like that?
> >
> > Thanks again! :)
> >
> > /Sofia
> >
> >
> > "Jeffery Hicks [MVP]" <jhicks@sapien.com> wrote in message
> > news:6D9C6E8C-5D7A-41EF-9014-6EC3D57D0E00@microsoft.com...
> >> An Exchange 2003 server needs SMTP installed but that doesn't mean it can
> >> route mail. If you are trying to send mail to an internal address, then
> >> any Exchange server should work. If you are trying to send to an
> >> external address then you'll need to check with your Exchange admins to
> >> find out what server is configured for that. You may also have to verify
> >> that it will relay messages for you. With that many Exchange servers I'm
> >> figuring there are some topology rules in place and you'll need to work
> >> with an Exchange admin.
> >>
> >> --
> >> Jeffery Hicks
> >> Microsoft PowerShell MVP
> >>
http://www.scriptinganswers.com
> >>
http://www.powershellcommunity.org
> >>
> >> Now Available: WSH and VBScript Core: TFM
> >> Coming Soon: Windows PowerShell: TFM 2nd Ed.
> >>
> >> "Sofia Engvall" <@> wrote in message
> >> news:uovvOuqNIHA.2376@TK2MSFTNGP02.phx.gbl...
> >>> Thanks for the fast reply Jeffery!! :)
> >>>
> >>> I'd found a working example at
> >>>
http://www.wisesoft.co.uk/Scripts/display_script.aspx?id=25 just before
> >>> you answered though it doesn't check the objectClass. The domain that
> >>> I'm working with right now doesn't seem to have any
> >>> 'msExchExchangeServer's that are of the 'msExchExchangeServerPolicy'
> >>> class though.
> >>>
> >>> My function to find an Exchange server now looks like this:
> >>> Function strGetSMTPServerName()
> >>> Dim objRecordSet : Set objRecordSet =
> >>> objSearchAD("<LDAP://"+GetObject("LDAP://RootDSE").Get("configurationnamingcontext")+">;(&(objectCategory=msExchExchangeServer)(!(objectclass=msExchExchangeServerPolicy)));name","whenCreated")
> >>> If Not objRecordSet.EOF Then
> >>> strGetSMTPServerName = objRecordSet.Fields("name")
> >>> Else
> >>> strGetSMTPServerName = ""
> >>> End If
> >>> End Function
> >>> (My objADSearch() function takes a objCommand.CommandText and
> >>> objCommand.Properties("Sort On") as arguments.)
> >>>
> >>> My problem now is that I don't know enough about exchange to know if all
> >>> exchange servers (we have about 20 in the domain) are able to send mails
> >>> using CDO.Message. Do I need to add some check that it actually can do
> >>> the job. It works fine when I test it but maybe the right server got on
> >>> top by luck...?
> >>>
> >>> Does all Exchange servers have SMTP installed?
> >>> Can all Exchange servers send E-Mails externally?
> >>> Does it matter at all which Exchange server I use?
> >>>
> >>> Thanks a million! :)
> >>>
> >>> /Sofia
> >>>
> >>>
> >>> "Jeffery Hicks [MVP]" <jhicks@sapien.com> wrote in message
> >>> news:ez%23PzWpNIHA.2000@TK2MSFTNGP05.phx.gbl...
> >>>>I haven't used this in a while but I think it will work:
> >>>>
> >>>> Dim objRootDSE
> >>>> Dim objConfiguration
> >>>> Dim cat
> >>>> Dim conn
> >>>> Dim cmd
> >>>> Dim RS
> >>>> Set objRootDSE = GetObject("LDAP://rootDSE")
> >>>>
> >>>> strConfiguration = "LDAP://" &
> >>>> objRootDSE.Get("configurationNamingContext")
> >>>> Set objConfiguration = GetObject(strConfiguration)
> >>>>
> >>>> 'select Exchange servers but not policies which happen to share the
> >>>> same class
> >>>> strQuery="Select distinguishedname,name,serialnumber,whencreated from
> >>>> '" & _
> >>>> objConfiguration.ADSPath & "' Where objectclass='msExchExchangeServer'
> >>>> " &_
> >>>> "AND objectclass<>'msExchExchangeServerPolicy'"
> >>>>
> >>>> WScript.Echo strQuery & VbCrLf
> >>>>
> >>>> Set conn=Createobject("ADODB.Connection")
> >>>> Set cmd=CreateObject("ADODB.Command")
> >>>> conn.Provider="ADSDSOObject"
> >>>> conn.OpenSet cmd.ActiveConnection=conn
> >>>> Set RS=conn.Execute(strQuery)
> >>>>
> >>>> Do While not RS.EOF
> >>>> if isArray(RS.Fields("serialnumber")) Then
> >>>> tmpArray=RS.Fields("serialnumber")
> >>>> wscript.Echo rs.Fields("name") & " (Created " &_
> >>>> RS.Fields("whencreated") & ")" & vbTab & tmpArray(0)
> >>>> RS.movenext
> >>>> Loop
> >>>> RS.Close
> >>>> conn.CloseYou'll need to modify it to return the information you need.
> >>>>
> >>>> --
> >>>> Jeffery Hicks
> >>>> Microsoft PowerShell MVP
> >>>>
http://www.scriptinganswers.com
> >>>>
http://www.powershellcommunity.org
> >>>>
> >>>> Now Available: WSH and VBScript Core: TFM
> >>>> Coming Soon: Windows PowerShell: TFM 2nd Ed.
> >>>>
> >>>> "Sofia Engvall" <@> wrote in message
> >>>> news:eRm#EvoNIHA.4480@TK2MSFTNGP06.phx.gbl...
> >>>>> Hi! :)
> >>>>>
> >>>>> I'm using CDO.Message to send e-mails in my scripts. I'd like my
> >>>>> function doing this to be able to work without requiring an explicit
> >>>>> smtp server as input. I want my scripts to function undependant of the
> >>>>> domain they are run in and all others do...
> >>>>>
> >>>>> Is there a way to get a list of the smtp servers in a domain? If so,
> >>>>> could I just use any one of these for the smtpserver setting? I don't
> >>>>> know much about mail servers...
> >>>>>
> >>>>> Thanks a million! :)
> >>>>>
> >>>>> /Sofia
> >>>>>
> >>>>>
> >>>
> >>>
> >
> >