WSH Practical Lecture---Lecture 3 Creating an Email
Author:Eve Cole
Update Time:2009-05-30 19:53:45
When creating mailboxes, the situation is complicated because you may use different email servers. Some put the email information in text files, some put the information in the registry, and some provide ADSI interfaces, so it depends on the specific situation.
For user email information in a text file, you can directly operate the text file. The following is a code example for writing a text file:
f
wxya
Set fs = WScript.CreateObject("Scripting.FileSystemObject")
Set fw = fs.CreateTextFile("c:users.dat")
fw.WriteLine "user1,[email protected],,,"
For user information placed in the registry, you can use WSH to directly operate the registry to complete the creation of the mailbox. For example, IMAIL's user information is placed in the registry.
Under HKEY_localmacineSoftWareIPswitchdomain. The only troublesome thing about the initial password of the mailbox is that we don't know its encryption algorithm. Therefore, we can only create a mailbox manually first, and then use a fixed password to see what it is after encrypting it. Our script will also use it when creating other mailboxes. The problem is that we must tell users that they must change their passwords in the future, otherwise it is unsafe.
Exchange Server provides ADSI interface, which makes it convenient to create mailboxes. And his mailbox can be synchronized with NT domain users. Here is a sample code:
objContainer = GetObject("LDAP://SERVERNAME/o=OrgName/ou=SiteName/cn=Recipients")
objUser = objContainer.Create("Remote-Address", "cn=CustRecip")
objUser.cn = "CustRecip"
objUser.Put "Target-Address", "SMTP:[email protected]"
objUser.Put "Internet-Encoding", 1310720objUser.UID = "CustRecip"
objUser.textEncodedORaddress = "c=US;a= ;p=DOIT;o=CDO;s=CustRecip;"
objUser.Mail = "[email protected]"
objUser.Put "otherMailbox", "MS:OrgName/SiteName/CustRecip"
objUser.Put "Replication-Sensitivity", 20
objUser.Put "MAPI-Recipient", False
objUser.SetInfo
WScript.Echo objUser.cn
For i = 1ToobjUser.PropertyCount
Set vProp = objUser.Next
WScript.Echo vProp.Name
Next
Note: Since I don’t have Exchange Server for experiments now, the above code has not been tested. If you have any questions, please go to its original source for solutions.
This script, with slight modifications, can also be used in ASP.