Register Your Component
April 3, 2000
Next, register your component with the system.
Type "regsvr32 WebMail" . You should see a
dialog box that announces that the component has been validly
registered.
Incidentally, if you ever want to change the functionality
of your component, you will have to:
- Change the Perl code, and the template
description of your object at the end of it.
- do NOT change the automatically generated
ID strings allocated to your component. The
same object should always be referenced by
the same unique ID strings.
- regenerate the DLL via PerlCtrl.pl -f or -d . To
do so, you are going to have to first UN register
the DLL containing the old COM object. To do so,
type "regsvr/u WebMail".
After you have regenerated the DLL, you will need to re-register
it to use it.
So, finally, let us write a brief ASP page to test our object.
<%
option Explicit
Dim mailer
Dim sent
set mailer=Server.CreateObject("WebMail.Mailer")
sent = mailer.send(
"[FROM]",
"[REPLY TO ADDRESS]",
"[TO ADDRESS]",
"[CC ADDRESS/ES]",
"[BCC ADDRESS/ES]",
"[SMTP SERVER IP ADDRESS]",
"[SUBJECT]",
"[MESSAGE BODY]",
"[FILE/S TO ATTACH]"
)
If(sent=false)Then
Response.Write(mailer.getError())
End If
If(sent=true)Then
Response.Write("Message sent")
End If
%>
Bear in mind that the underlying module that
is going to be performing the mailing is
Mail::Sender. As a result, you can count
on Mail::Sender's behavior, so that the
CC and BCC addresses can be comma-separated
strings.
Filenames for attachments ought to be absolute
paths from root.
Running the page in your browser will send the
mail according to the parameters that you have
inserted in your ASP page.
Once you have grasped the fundamentals contained
within this article, writing other COM objects in
Perl simply comprises variations on a theme.
- Write your Perl code. Test that it works as pure Perl.
- Generate the template description of the functionality
of your class via PerlCtrl.pl with the -t flag.
- Customize the template.
- Attach the template to your code, and package your code
as either a freestanding or dependent COM object.
- Register and use the COM object you have created.
Paste the Template Code
Introduction to Perl on Windows - Table of Contents
|