This is the same process as you are familiar with in Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com... CDO 2.0 provides access to SMTP and NNTP Simpo PDF Merge
Trang 1attachments." & vbcrlf & _
If the list is restricted to members only, you query the Subscribers table for
the sender’s address If it is not found (.EOF is set), the sender is not a
Trang 2For a real mailing list, you usually want to set the Sender to the person who
contributed the message and set a separate SMTP Reply-To field to the
address of the mailing list Readers can then see the contributor’s name, but
set the Reply-To To work around this problem, you put the sender’s email
address into the body of the message I leave it as an exercise for you to
implement this functionality by replacing the set
oNewMessage=oSession.Outbox.Messages.Add with set
oNewMessage=CreateObject("CDONTS.NewMail") (Don’t forget to set
oMessage=nothing after each message is sent.)
For proper operation of the list, you should open each attachment in the old
your case, you simply attach the existing message, and it will then carry all
Trang 3’ Delete this message from the inbox
The sendNotice function sends a notification message as a reply to the
sender It reports on subscription status or the reason why the message was
not sent out It follows the standard method to send a message Note that it
includes the moderator as a Bcc recipient so she is aware of these
Trang 4•Information Stores—An Information Store holds messages in a persistent
•Address Lists—An address list holds addresses in a persistent manner Like
You must create a profile to use with the sample scripts You will create a profile called
"WSH" that connects to a Personal Folders service, a Personal Address Book service,
Trang 5Use MyInbox.pst from the Web
Use MyBackup.pst from the
Use MyAddresses.pab from the
Internet Mail or some other
Delivery Service such as
commands you must have a delivery service configured that works with Internet addresses
You can use your existing Internet account.
Trang 7The method Logon([ProfileName], [ProfilePassword], [showDialog], [newSession],
[parentWindow], [NoMail], [ProfileInfo]) is quite different Because you must log on to a profile, you give the ProfileName and ProfilePassword Set showDialog to True if you
want a dialog box to be shown to help the user to select a profile By default, Logon will attach to an existing session if one is already running from Outlook or another program Set newSession to True to always establish a new session Here is an example of the
You can avoid creating a profile in advance if you want to connect only to an Exchange
the message It is a byte location and is the first character of the message Note that the
AddressEntry in an AddressList whose name or address matches the text
address cannot be resolved This is the same process as you are familiar with in
Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com
Trang 8typed into the To: line to underline.
Reading messages from the Inbox using CDO is very similar to CDONTS, except you
Trang 9collection contains all the messages in the Inbox You sort the collection
property being sorted, or it is the unique binary identifier for that property Some
information stores do not support passing string property names or descending sorts
Messages in CDO don’t have to be emails As a result, there might be no sender or
recipient For this reason, you have to trap errors and check the error code
Trang 10WScript.echo " (No Sender)"
oRecipient.Type indicates whether they were a "To", "Cc" or "Bcc" recipient
oAddressEntry.Type is the address type, such as SMTP:
CDO enables you to have many Information stores in one profile An example is to have
a primary and a backup PST file, as you have, or an Exchange mailbox and an Archive
Trang 11.Name You prompt the user for the source and target information stores:
identifier that can be used to identify uniquely a messaging object: Folder, Message,
Trang 12You want to create a new folder for each backup This goes through all the top-level
folders in the target store to determine whether your folder exists If it already exists, you
[name], [subfolders]) This copies the oFolder object to the destination folder
work in a very similar manner:
Trang 13WScript.echo " ***Problem copying folder " & err.number & "-" & err.description
the CDO and CDONTS documentation The information is also available on the MSDN
CDONTS is a very simple interface that works with Internet addresses It runs only
on messaging servers running Internet Information Server CDO works with any
server or client with Outlook installed CDONTS supports MHTML, a standard that enables multiple HTML components in an email message The current version of
Recipients in both environments include the address, the address type, To,
Carbon-copy, and Blind-carbon-copy Where they differ is that a CDONTS
Recipient includes the address information, whereas the CDO Recipient
co-exist with both CDO and CDONTS CDO 2.0 provides access to SMTP and NNTP
Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com
Trang 14services with or without MIME support It provides a comprehensive mechanism to form and manipulate MHTML messages CDO 1.2 will continue to play a key role in
Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com
Trang 15Day 20: Using WSH with Custom VB and Java
By now, you’ve seen how powerful the Windows Scripting Host can be The scripting
languages themselves provide useful functionality Coupled with the built-in Windows scripting host objects, you can perform an infinite variety of useful automated tasks If the WSH objects aren’t enough, you can always use objects provided by other software
input dialog boxes This chapter shows you how to create objects using Visual Basic
WSH to Access Databases Through Microsoft Active Data Objects (ADO)" and Day 17,
"Using ADO for WSH Scripting Tasks," how it can be used to call Microsoft Active Data
Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com
Trang 16For the first example, you’re going to develop a Visual Basic object that allows you to
display an Enter Password dialog box The object that you create will be basic It will
return true if the user clicks OK or false if the user decides to cancel.
The Visual Basic object will be implemented using two pieces A Visual Basic class will
provides space to enter a username and password, and to click an OK or Cancel button The Visual Basic class is what you will access from your WSH script; it hides the
implementation details of the form that you use to display the input dialog When you
Password properties As far as the sample script is concerned, it has no idea that the form exists.
This example assumes some familiarity with Visual Basic We are going to cover the
steps involved in assembling the object, but we aren’t going to discuss the details of
Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com
Trang 17you for the type of project that you want to create Next, follow these steps:
Trang 18MaxButton to False; change MinButton to False; then change the
StartUpPosition to 2-CenterScreen Next, add controls to the form.
the Caption to &Password:.
Next you need to add text boxes that allow the user to enter his name and
property to "" and change (Name) to txtName Add another text box for the
password, set Text to "", change (Name) to txtPassword, and set
All that's left is to add OK and Cancel buttons At the bottom of the form, add a
button and set the Caption to &OK, the (Name) to cmdOk, and Default to true Add another button next to the OK button, and set the Caption to &Cancel, the (Name) to cmdCancel, and the Cancel property to true.
Trang 19following After you’re finished, your screen should look similar to Figure 20.7.
Trang 20class, add the following code:
Trang 21WSHLogin Change the project properties by choosing Project, WSH Login
Properties from the menu Set Project Type to ActiveX DLL and then click OK Save the project by choosing File, Save Project You can save the parts of the project
After you’ve saved the project, switch to the Login form Your screen should look like Figure 20.9.
Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com
Trang 22GetLoginDetails, which are exposed by the class.
Visual Basic class The new public properties will be available the next time
Using the Login Details dialog from WSH is simple All you need to do is create an
WSHLogin.clsLogin, which represents the object Then you can call the
GetLoginDetails() function to display the dialog shown in Figure 20.11.
Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com
Trang 24
For the next example, you’re going to develop a Java object using Microsoft Visual J++ 6.0 that allows you to display an Enter Password dialog box that is identical to the dialog box in the preceding Visual Basic example Like the Visual Basic object, it will provide username and password properties and the getUserDetails() function.
Also like the Visual Basic example, the Java example will be implemented using two
pieces The Login class will provide the object interface for the object, and the
LoginForm class will provide the user interface.
Before you go through the example, be forewarned that the ActiveX/Java
integration is a capability provided specifically by the Microsoft Java
Virtual Machine You can’t use these techniques with the standard Java
This example assumes some familiarity with Visual J++ You are going to cover the
steps involved in assembling the object, but you aren’t going to discuss the details of
coding using Visual J++.
Run Microsoft Visual J++ Select the Components category, and then the COM DLL
Trang 25Add a new form by selecting Project, Add Form from the menu In the dialog that
startPosition property to Center Screen Set the minimizeBox and
maximizeBox properties to false Finally, change the borderStyle to Fixed
Next, add a bunch of controls to the form First, add a Group Box control Change
User &Name Add another label and change the text property to &Password.
property to "", the name property to editPassword, and the passwordChar
name to btnOk Add a button next to that button and change the text property to
&Cancel and the name to btnCancel.
Trang 26the project explorer and select view code You should see code that looks like the code in Figure 20.17.
Trang 27
Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com
Trang 28add the following code:
Trang 29Save your project Then select Build, Build from the menu Your classes should
Choose View, Expert Mode to make sure that setting is on Expand the tree under Object Classes, Grouped by Component Category, Java Classes You should find VJLogin.Login in the list; Figure 20.21 illustrates how it shows up.
Trang 30Like the previous example, you can easily add more fields to the dialog For
each field, simply add a label and an edit box As you get more experienced,
Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com
Trang 31no matter the language, it can be used just the same as any other COM object.
Trang 32
You can extend the Windows Scripting Host using any language that provides the
capability to create COM objects In this chapter, you used Visual Basic and Visual J++
to create objects that you can use from within WSH scripts The custom objects allow you to present a better, more functional user interface than you can present using the
If you want to distribute scripts that use the custom objects that you’ve built, you need
to create an installation program for the custom objects The installation program
ensures that the object is registered on the user’s machine with all the correct DLL
Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com
Trang 33Day 21: Deploying Script Solutions
Directory; sending and receiving messages with collaborative Data Objects; and
creating custom objects, which you learned in the previous chapter.
of the organization Do the computers in your organization meet the hardware and
software requirements for Microsoft Windows Script Host? Do you know how to deploy Windows Script Host to users who don’t already have it? What about scripts; do you
know the best way to run scripts on users’ computers? On this, the 21st day of this
book, you will
If you were planning to deploy a new operating system to hundreds or thousands of
seats, you would plan and test carefully You should Don't take deploying Windows
Script Host or your scripts quite that seriously First, treating this process as a major
deployment costs a lot of loot and, beyond cost, you're unlikely to convince
management that you need a team to help you write specifications and deploy a handful
That doesn't mean that you shouldn't be smart about deploying Windows Script Host
and scripts With a bit of forethought, deploying the required files can be a process that
is business as usual In all cases, while sitting at your own desk, here are some steps to
Determine what you need to deploy—Do you need to deploy a new version of
Windows Script Host? Do you need to deploy a script? Make sure you have a handle
on which versions of which files you need to deploy (a topic you learn more about in this chapter).
Determine to whom you need to deploy—Are you deploying to all users in the
organization or just some groups or some users? Who are they? For example, if
accounting is using an outdated version of Windows Script Host but you want to use the new features of version 5.0, target that particular group.
Determine how you’re going to deploy—This chapter presents a number of
alternatives for deploying Windows Script Host and scripts Choose the alternative that
is best for the files you're deploying and your target Don't go overboard, however For instance, using Microsoft Systems Management Server to deploy a script to 10 users
is overkill You would be better off walking around with a floppy disk.
Trang 34If you have an aptitude for journalism, you might be asking yourself what happened to
the when and where part of who, what, when, where, and how Considering the
deployment advice you learn in this chapter, timing doesn’t mean much You’re not
going to bog the network down with this deployment and, in most cases, you’re going to
deploy as part of users’ logon scripts That leaves the where Part of the process you
learn in this chapter is creating network shares from which users’ logon scripts install
files You also learn, later in this chapter, about directory conventions that make sure
Part of your deployment planning should be testing your scripts In many
organizations, network administrators get a reputation for shutting down
the server at the wrong times and breaking computers with faulty software, among other things Don’t let a buggy script add fuel to the fire.
Windows Script Host, and thus your scripts, will run anywhere a suitable (32-bit
Windows) operating system will run Thus, if a computer runs Microsoft Windows 98
well, the host will run well on that same computer If a computer runs Microsoft Windows
95 with Microsoft Internet Explorer 4 well, the host will also run well.
To clarify the requirements for Windows Script Host, examine the hardware
requirements for each Microsoft operating system Windows 95, Windows 98, Windows
NT Workstation 4.0, and Windows 2000 Professional have many requirements in
common They all require a VGA or better resolution monitor and a mouse or similar
pointing device None require a CD-ROM drive, but all are less cantankerous if one is available Processors and memory are different stories, however No version of 32-bit Windows runs well on anything less than a Pentium or compatible processor Windows
95 and Windows 98 require at least 32MB of memory to avoid tapping the user’s
patience, but 64MB makes for a better experience Windows NT Workstation 4.0 and Windows 2000 Professional are nothing short of doggish on a computer that doesn’t
have at least 64MB of memory, but you’ll go from ho-hum to wow on a computer with at least 96MB.
additional space The disk space requirements for the host and your scripts should
never really be an issue, however, because a healthy computer always has far more
All 32-bit versions of Windows, except Windows 95, meet the minimum software
requirements for Windows Script Host To install Windows Script Host in Windows 95, however, you must install OSR2 or install Internet Explorer 4 or better On computers without either, you can still install Windows Script Host version 5.0, the latest version, if
you install DCOM DCOM, which stands for Distributed Component Object Model,
allows COM components (ActiveX controls, scripts, and so on) to communicate across networks.