Date created:20-aug-97
I had much requests after one of my postings in the ASP mailing list, that I decided to put the sample on my web. From technology view of point, it is already outdatet. But it looks like not each one goes with MS's speed and need some older stuff.
Sending mail with MAPI is easy under some conditions. If you have MS Exchange Server installed, you can use the CDO (Collaboration Data Objects) or the toolkit coming with V5.5 If only MS Mail postoffices (MS Mail V3.2 to V3.5) are installed, one can use the predecessor of CDO, the Active Messaging (V1.1). Additionally, one need a MAPI aware product like the "full" MS Exchange Client or the newer MS Outlook CLient. "Full" means, you cannot use the client which is delivered with the OS itself.
Naturally, that's really silly to install such software at a server machine and I think this is only for MS licensing reasons (the client delivered with the OS has not the same level of interaction with the Active Messaging Library).
I had no try to use the new objects coming with Windows NT Option Pack2. Normally, they should give the simplest solution to send mail from ASP pages. But they allow only to send mail, there is no access to the underlying storage system (folders) and MAPI cannot be used as protocol. So they are out of focus if you need reading mail and doing some manipulation of folders and contents or something else.
The example is used to allow a user sending a message via mail, in my case, to a "webmaster".
There are things to consider: I have modified the registry settings for WSH
in that manner, that I can type "myscript" instead of "CSCRIPT myscript.VBS".
This must even be true for the scheduler service user and my sample!
You can schedule with
cscript too. There are a lot of restrictions with the Windows NT scheduler service.
You can not have console output. Writing to STDERR or STDOUT is useless.
In mbFileMail2.vbs all messages are written with the WSCRIPT.ECHO method
which do'nt go out in the batch. I am working an detecting running with the
scheduler and sending all output to a logfile instead of WSCRIPT.ECHO. Therefore
I have centralized all output in a "PutCon" subroutine, but thats not ready. You
could decide to schedule a cmd procedure from ASP which runs the VBS script
via calling cscript.exe.
With this, you can redirect output. Redirecting with the "PutCon" routine
is the easiest way.
The command line length for the scheduler command "AT" cannot exceed 259
characters. So, if you have long subjects and a long path, you'll get a problem.
Use a short path for the location of the files and be aware to always define
to full path to the file. If you cannot fullfill this restrictions,
you should write a textfile from asp and read it in in the sending wsh script.
Some data about my environment at creation date:
I use - Windows NT V4, Service Pack 3, admin hotfix, - ASP V3.0 - OLE Messaging V1.1a - Windows Scripting Host V1.0 - VB Script V2.0
My domain name is "MBG", my servername is "M1". My profilename for sending in the example is "IUSR_M1". So enough help, I hope you have all what you need and it useful for you!
Remark:
All files are with extension ".txt" for some reasons. So, if you
just click the link, you'll get them in your browser. Alternately, you
could use the mous's right button to get the "save target as..." and
a "sorry" for the whole german comments in the files.....