Microsoft KB Archive/248734

{|
 * width="100%"|

-

The information in this article applies to:


 * Microsoft Internet Information Server 4.0
 * Microsoft Visual Basic Enterprise Edition for Windows, version 6.0
 * Active Server Pages

-

SUMMARY
By 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.

The concept used in this article is similar to the SMTP Relay SMARTHOST mechanism. However, it does not require the STMP Server to be installed on the same computer with IIS4.

The two servers needed for this setup are:

IIS4 as DCOM client

SMTP server with a custom DCOM EXE server using the CDONTS.NewMail component.

MORE INFORMATION
Create 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.

You can alternatively run "Project1.exe /REGSERVER" from the command line manually.

Execute the following script at SMTP Server's command prompt in order to remotely register the class to IIS.

clireg32.exe project1.vbr -s  -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" 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.

Set AspAllowOutOfProcComponents to "1" by using METAEDIT.exe from IIS Resource Kit, or use ADSUTIL.vbs with relevant parameters.

For additional information, please see the following article(s) in the Microsoft Knowledge Base:

"Q\]\] How To: Allow ASP Pages to Launch .EXE's with IIS 4.0, 5.0" Check the Registry and DCOM permissions to see if they are correct on SMTP Server.   Adjust MSVBVM60.dll, Project1.exe Registry Key Permissions to allow them to be queried by the user context of the running processes, if you are not sure set Everyone to have read access at least.

For additional information, please see the following article(s) in the Microsoft Knowledge Base:

"Q\]\] DCOM Client Hangs and Then Gives Error 429" Run DCOMCNFG.exe. Select Project1.SendMail and click Properties and then set "Authentication Level" to None. This is done because you do not want to suffer from NTLM authorization three round trips. You can prefer any authentication level depending on your needs.