I want to put the address of the email relay server into an absolutely globally accessible variable as in our environment the address to use is the same across an entire server, but may change between servers. And it does change between our development, internal prod, and external prod environments.

ifyou have multiple applications from where you wish to get this same info, then the best way is to create an entry into the Windows registry andread it on applicaiton_onstart of each application. That way it will resolve this issue across applications.

randeeps,
You said that the servervariables are read from the metabase, do you know where in the metabase? I looked through and do not see them. Plus many of them are more dynamic than metabase reads would cover.

I didn't miss the conversation at all, what you are trying to do is near impossosible, as no-one should go and edit their metabase, becasue 1 typo will make your entire server crash.

Your best bet is to set the variable in the global.asa file for each site.

Unless, that is, you set up an SMTP server within IIS to use CDONTS.

Right Click 'My Computer', go to 'Manage', right click 'Internet Information Services' and click 'Properties' on the second tab (Server Extensions), right in the middle shows 'Options' Specify how mail is sent. Click on settings and fill out the info.

I've reviewed the servers and doing it application level is not going to work, some of the applications do not have a global.asa file, and the shear number of applications makes adding new code rather infeasible, replacing a mail server address with a new value, or a built-in function call to get the value, is feasible.

>>keepin mind that no matter what solution u go for, you have to change the mailserver code in all the apps to pickup frmo the registry.

I mean

keepin mind that no matter what solution u go for, you have to change the mailserver code in all the apps.

The registry has a better solution over just using application variable... as all apps will again require change if mailserver changes. so better solution to incorporate performance will be as I suggested before is to store the mailserver in registry and then in applcation_onstart to pick the mailserver from registry and store in app varaible.. but you haveto look into how frequently the maislerver info will change... if very frequently then just access registry directly everytime you want the mailserver info.

I'm sure the web server will have a maintenance reboot between the time we find out we need to change the SMTP address and the time the old one goes offline, so application level storage is ok, but there is no feasible way of getting the code into every existing (and non-existing) global.asa.

either route you go, you will end up having to code something in each application, unless like you want to edit the metabase (which I strongly recommend against), besides I don't believe you can set a variable in the metabase

Ok, I have a snag in using the registry. I created the key and string value that I want to read, but of course the web site does not have permission to that location in the registry. Rather than changing permissions on the registry, is there a location in the registry than the default anonymous account has access to?

then you are S.O.L., because unless you want to give the world access to your servers registry, there is no other way other than stated above. Which means you will have to add code to every single application, whether you use a global.asa file, or a function, or whatever you decide to use. You will have to implement it in every single application on your server.

But...then again, you don't have to listen to us. Devise your own method, or allow anonymous access to your servers registry and see what happens, someone will eventually realize that you have done this, and bring down your server.

I only mention global.asa, because having this file in an ASP application is global, meaning it effects the entire site, and not just the files you apply it to.

Building a function is great, because you can call it from any file (so long as it is included in the file), but it is not global to the application.

Whatever method you decide to use, good luck to you, but please, do let us know if you decide to allow anonymous access to your machines server, I know plenty of people who I am sure would love to know this

1. Create a string directly under HKLM i.e Local Machine. Left click on the HKEY_LOCAL_MACHINE. Right click onthe right panel and create a new STRING and name it MAILSERVER. Enter the value of the mailserver and close the registry.

2. create a Test.asp and paste the code below
<%
on error resume next
Set WshShell = Server.CreateObject ("Wscript.Shell")
If Err <> 0 Then
Response.write Err.description & "<br>" & Err.number
response.end
end if

4. run the test.asp in the browser and Voila!!! you will find the value of the mailserver string displayed to the user.

I think access to strings directly under HKLM does not require special permissions. atlease the same above proves it if it also works at your end.

5. Using registry or flat file only solves the problem of centrally storing the mailserver details. You will haveto create a global.asa file under each app (if not available) and then access this registry key in application_onstart and set in application variable. So any reference of mailserver data in any page should be made using the value stored in the app variable as iut contains the maislerver detail stored in the registry.

Now the problem will be how to notify your applications of updates to new mailserver details if your existing mailserver goes down - this can be done by creating a new asp page which will do nothing but uipdate the appliocation variable with the new value from the registry. Simple as that. Howeve when you do this make sure you lock the application variable and thneset the new value. Make sure you unlock the variable after setting so that the pages can access the variable.

No I didn't try it, I instead built a DLL to do the work and I have it working in my test environment. The syntax to do what I need makes it workable as I can do Server.CreateObject("MyObject").GetSMTPAddress and just replace the current SMTP address inline. Not the solution I was hoping for, but it is close enough and will work once I figure out how to deploy it on non-development servers.