The information in this article applies to:
SUMMARYBy using the DCOM technology with the CDONTS.NewMail component, you can send e-mail from an ASP Web page without having an SMTP server installed on the Internet Information Server 4.0 (IIS) computer that you want to initiate the send on. Therefore, installing the SMTP service may be omitted on the IIS. IIS4 as DCOM client
SMTP server with a custom DCOM EXE server using the CDONTS.NewMail component.
MORE INFORMATIONCreate a sample Visual Basic project with the following options and settings: Project Type: ActiveX EXE Project Name: Project1 Class Instancing: MultiUse Class Name: SendMail Other project settings/options: check Unattended Execution check Upgrade ActiveX Controls select ActiveX Component check Remote Server Files select Binary Compatibility set Thread Pool to 10 threads NOTE: After compiling the project in Visual Basic 6, copy Project1.exe , Project1.vbr and Project1.tlb to an appropriate folder. On the SMTP Server Open file explorer double-click on the Project1.exe, so it registers automatically. clireg32.exe project1.vbr -s <IISServerHostName> -t project1.tlb -d Visual Basic 6 Project Source Code: Option Explicit Public strFrom As Variant Public strTo As Variant Public strReply_To As Variant Public strSubject As Variant Public strBody As Variant Public intBodyFormat As Integer Public intMailFormat As Integer Public intImportance As Integer Public Sub SendMail() Dim objNewMail As CDONTS.NewMail Set objNewMail = CreateObject("CDONTS.NewMail") objNewMail.From = strFrom objNewMail.To = strTo objNewMail.Subject = "This is a test message" objNewMail.Body = strBody objNewMail.Value("Reply-To") = strReply_To objNewMail.BodyFormat = intBodyFormat objNewMail.MailFormat = intMailFormat objNewMail.Importance = intImportance ' Send the message and cleanup CDONTS objects objNewMail.Send Set objNewMail = Nothing End Sub Sample ASP code that works as the DCOM client on IIS. <%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit Dim myCDONTSMail '---- BodyFormat Property ---- Const CdoBodyFormatHTML = 0 ' The Body property is to include Hypertext Markup Language (HTML). Const CdoBodyFormatText = 1 ' The Body property is to be exclusively in plain text (default value). '---- MailFormat Property ---- Const CdoMailFormatMime = 0 ' The NewMail object is to be in MIME format. Const CdoMailFormatText = 1 ' The NewMail object is to be in uninterrupted plain text (default value). '---- Importance Property ---- Const CdoLow = 0 ' Low importance Const CdoNormal = 1 ' Normal importance (default) Const CdoHigh = 2 ' High importance ' Create the CDONTS NewMail object Set myCDONTSMail = CreateObject("myCDONTS.class1") myCDONTSMail.strFrom = "yourFromAddress@domain.com" myCDONTSMail.strTo = "intendedRecipient@anotherdomain.com" myCDONTSMail.strSubject = "This is the Subject" myCDONTSMail.strBody = "This is the message body." myCDONTSMail.strReply_To = "Reply-To<yourFromAddress@domain.com>" myCDONTSMail.intBodyFormat = CdoBodyFormatText myCDONTSMail.intMailFormat = CdoMailFormatText myCDONTSMail.intImportance = CdoNormal ' Send the message and cleanup CDONTS objects myCDONTSMail.SendMail Set myCDONTSMail = Nothing %> WARNING: Make sure that IIS MetabaseSetting is set to allow out of process components on the IIS Server.
Check the Registry and DCOM permissions to see if they are correct on SMTP Server.
REFERENCESFor additional information, please see the following article(s) in the Microsoft Knowledge Base:
Additional query words: CDONTS SMTP IIS DCOM COM VB ASP Keywords : kbASP kbIIS |
Last Reviewed: January 13, 2000 |