|
Back to the top of the FAQ
The OCXMail ASP component
allows you to send mail using the standard
SMTP protocol from any program that can use ActiveX/OLE components.
The samples
here have been checked against
IIS and ASP.
Installation
The installation procedure installs aspmail.ocx into the
installation directory and the system32 directory if necessary.
Support files (mfc40.dll and msvcrt.dll) are installed into the system32 directory if necessary.
System Requirements
You will need a system that support OCX components, and software
that can contain an OCX component in order to use the OCXMail OCX component.
If you want to send email from webpages,
you will need IIS V3 with ASP installed,
or another webserver that supports ASP.
File Names
|
ASPMail.ocx
|
The OCXMail ASP component. Type regsvr32 ASPMail.ocx at the
command line to register on your system.
|
Syntax
Set Mailer = Server.CreateObject("ASPMAIL.ASPMailCtrl.1")
Parameters
-
Mailer
-
Specifies the name of the object created by the call to Server.CreateObject.
Registry Entries
None.
Properties
None.
Methods
|
SendMail
|
Sends the electronic mail message.
|
|
SMAttach
|
Sends the electronic mail message. with attachment(s)
|
|
SendX
|
Sends the electronic mail message. with attachment(s), blind copies, and other options.
|
|
|
|
|
XHeader
|
Adds or overrides any X-Header, for example to change the character set to
ISO-8859-1, change the message's date, or change the Content-Type, etc.
|
Advanced Methods
Bonus Methods
|
RandomString
|
Creates a random string of specified length.
|
|
Sleep
|
Sleeps (waits) for specified number of milliseconds.
|
|
PreScreenEmailAddress
|
Pre-screens an email address, to see if it is syntactically correct.
|
Perl Example
The following sends an email from Perl
"Andy Rebele" <ahr@cityauction.com>:
The version of Perl I use is Build 315 from ActiveState:
http://www.activestate.com
It comes with the OLE module ole.pm
Here is an example of using Perl to send with ocxMail. It uses Text::Wrap
(a package to do word wrapping). There are no other modules necessary.
----------
use OLE;
use Text::Wrap qw(wrap $columns);
sub sendOCXMail
{
my($ToAddresses, $FromAddresses, $Subject, $Body, $WordWrapWidth) = @_;
my($initial_tab) = "";
my($subsequent_tab) = "";
my($NewBody) = "";
my($result, $mailer);
$columns = $caEmailWidth;
if ($WordWrapWidth) {
if (($WordWrapWidth > 10) && ($WordWrapWidth < 100)) {
$columns = $WordWrapWidth;
}
}
if ($columns <= 10) {
$NewBody = $Body;
} else {
$NewBody = wrap($initial_tab, $subsequent_tab, $Body);
}
$mailer = CreateObject OLE "ASPMAIL.ASPMailCtrl.1";
$result = $mailer->SendMail($caSMTPServer, $ToAddresses, $FromAddresses,
$Subject, $NewBody);
undef $mailer;
return $result;
}
Visual Basic Example
The following sends an email from Visual Basic
Dim Mailer As Object
Dim recipient
Dim sender
Dim subject
Dim Message
Dim mailserver
Dim result
Set Mailer = CreateObject("ASPMAIL.ASPMailCtrl.1")
recipient = "peter@domain.com"
sender = "jacqui@domain.com"
subject = "The Subject"
Message = "This is the message part"
mailserver = "yourmailer.domain.com"
result = Mailer.SendMail(mailserver, recipient, sender, subject, Message)
If "" = result Then
MsgBox ("Mail has been sent.")
Else
MsgBox ("Mail was not sent, error message is " & result)
End If
ASP Example
The following sends an email from ASP
<% Set Mailer = Server.CreateObject("ASPMail.ASPMailCtrl.1") %>
<%
recipient = "Joe@mailer.net"
sender = "Cheryl@mailer.net"
subject = "Great Program"
message = "Thanks, it works a treat!"
mailserver = "mailer.flicks.com"
result = Mailer.SendMail(mailserver, recipient, sender, subject, message)
%>
<% If "" = result Then %>
<P>
Mail has been sent.
<P>
<% Else %>
<P>
Mail was not sent, error message is
<H2>
<%= result %>
</H2>
<P>
<% End If %>
SQL Server Example
CREATE PROCEDURE ActiveX1
AS
-- Declare variables.
DECLARE @strAccountName varchar(20)
DECLARE @strMessage varchar(255)
DECLARE @strSMTPServer varchar(32)
DECLARE @strFromName varchar(32)
DECLARE @strFromAddress varchar(32)
DECLARE @strPriority varchar(32)
DECLARE @strReturnReceipt varchar(255)
DECLARE @strToAddressList varchar(255)
DECLARE @strCcAddressList varchar(255)
DECLARE @strBccAddressList varchar(255)
DECLARE @strAttachmentList varchar
DECLARE @intObject int
DECLARE @intResult int
DECLARE @strReturn varchar(255)
DECLARE @strMessageSubject varchar(255)
DECLARE @strMessageText varchar(255)
DECLARE @intSupplierID int
-- Set constants.
SELECT
@strPriority = 'High',
@strReturnReceipt = 'No',
@strCcAddressList = '',
@strBccAddressList = '',
@strAttachmentList = '',
@strFromName = 'Administrator',
@strSMTPServer = 'mySMTPserver.com',
@strFromAddress = 'Administrator@flicks.com',
@strMessageSubject = 'Junk mail',
@strMessageText = 'Just another piece of spam.',
@strToAddressList = 'Innocent_Victim@flicks.com'
-- Create ocxmail object.
EXEC @intResult = sp_OACreate 'ASPMail.ASPMailCtrl.1', @intObject OUT
IF @intResult <> 0
BEGIN
EXEC sp_displayoaerrorinfo @intObject, @intResult
RETURN
END
-- Call SendX method.
EXEC @intResult = sp_OAMethod @intObject, SendX, NULL, @strSMTPServer, @strFromName,
@strFromAddress, @strPriority, @strReturnReceipt, @strToAddressList,
@strCcAddressList, @strBccAddressList, @strAttachmentList, @strMessageSubject,
@strMessageText
IF @intResult <> 0
BEGIN
EXEC sp_displayoaerrorinfo @intObject, @intResult
RETURN
END
-- Destroy ocxmail object.
EXEC @intResult = sp_OADestroy @intObject
IF @intResult <> 0
BEGIN
EXEC sp_displayoaerrorinfo @intObject, @intResult
RETURN
END
GO
http://www.flicks.com/authentix/discover/main.htm
Back to the top of the FAQ
|
|