PSS ID Number: Q176914
Article Last Modified on 07-16-2001
This article describes how to create a Web application that uses an Hypertext Markup Language (HTML) page, an Active Server Page (ASP) and a Visual Basic ActiveX .dll to send mail when Microsoft Exchange Server and Microsoft Internet Information Server are installed on separate machines.
To use an ActiveX .dll in an ASP page to send mail when the
Internet Information Server (IIS) and Exchange servers are not on the same
computer, you need to set up Windows NT and IIS security so the user can
log onto the Exchange server.
This article provides a step-by-step method that includes all source code
required.
General tab:
Project Type: ActiveX .dll
Startup Object: (None)
Project Name: CDOMail
Project Description: CDO .dll to send mail
Unattended Execution: Checked
Make tab:
Title: CDOMail
All other settings as desired.
Compile tab:
All settings as desired.
Component tab:
Remote Server: Unchecked
Version Compatibility: Project Compatibility (Change to
Binary Compatibility after compiling
to maintain client-server compatibility.)
Name: clsSendMail
Instancing 5 - MultiUse
Option Explicit
'Requires a reference to OLEMSG32.DLL version 5.0.1458.49 or later
'or CDO.DLL version 5.5.1664.0 or later.
'Local variable(s) to hold property value(s).
Public Recipient As Variant
Public Subject As Variant
Public Text As Variant
Public Mailbox As Variant
Public Server As Variant
Public Sub Send()
Dim objSession As MAPI.Session
Dim objOutbox As Folder
Dim objNewMessage As Message
Dim objRecipients As Recipients
Dim objOneRecip As Recipient
Set objSession = New MAPI.Session
objSession.Logon profileinfo:=Server & _
vbLf & _
Mailbox, _
nomail:=True
Set objOutbox = objSession.Outbox
Set objNewMessage = objOutbox.Messages.Add
Set objRecipients = objNewMessage.Recipients
Set objOneRecip = objRecipients.Add
With objOneRecip
.Name = Recipient
.Type = ActMsgTo
.Resolve ' Get MAPI to determine complete E-mail address.
End With
With objNewMessage
.Subject = Subject
.Text = Text
.Send
End With
End Sub
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Developer Studio">
<META HTTP-EQUIV="Content-Type" content="text/html;
charset=iso-8859-1">
<TITLE>Document Title</TITLE>
</HEAD>
<BODY BGCOLOR=White>
<H1><CENTER>Test</CENTER></H1>
<P><H2><CENTER>Enter Valid Logon and Exchange
Server</CENTER></H2>
<P>
<FORM ACTION="CDOMail.asp" METHOD="POST" NAME="frmUserData"
OnSubmit="return ValidateData()">
<TABLE>
<TR>
<TD>Mailbox:</TD>
<TD><INPUT TYPE=TEXT VALUE="Mailbox" NAME="txtMailbox"
ALIGN=LEFT></TD>
<TR>
<TD>Exchange Server:</TD>
<TD><INPUT TYPE=TEXT VALUE="Exchange Server" NAME="txtServer"
ALIGN=LEFT></TD>
<TR>
<TD>Recipient:</TD>
<TD><INPUT TYPE=TEXT VALUE="Recipient" NAME="txtRecipient"
ALIGN=LEFT></TD>
<TR>
<TD>Subject:</TD>
<TD><INPUT TYPE=TEXT VALUE="This is the subject."
NAME="txtSubject" ALIGN=LEFT></TD>
<TR>
<TD>Message:</TD>
<TD><TEXTAREA NAME="Name" ROWS=10 COLS=40
WRAP=Physical></TEXTAREA></TD>
</TR>
</TABLE>
<INPUT TYPE=HIDDEN VALUE="None" NAME="hidSource"><BR><P>
<INPUT TYPE=SUBMIT VALUE="OK" NAME="btnSubmit" ALIGN=RIGHT>
<INPUT TYPE="RESET" VALUE="Reset">
</FORM>
</BODY>
</HTML>
<%@ LANGUAGE="VBSCRIPT" %>
<%
If Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 access denied"
Response.End
End If
%>
<%
Response.Write("Logon User = " &
Request.ServerVariables("LOGON_USER") &
"<br>")
bstrProfileInfo = Request.Form("txtServer") & vbLf &
Request.Form("txtMailbox")
response.write bstrProfileInfo %><br><%
%>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//EN">
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
dim MyMail
Response.Write("About to CreateObject CDOMail.clsSendMail.<br>")
Set myMail = CreateObject ("CDOMail.clsSendMail")
Response.Write("CDOMail.clsSendMail Created<br>")
myMail.Server = Request.Form("txtServer")
myMail.Mailbox = Request.Form("txtMailbox")
myMail.Recipient = Request.Form("txtRecipient")
myMail.Subject = Request.Form("txtSubject") & now
myMail.Text=Request.Form("txtMessage")
Response.Write("myMail.Server= " & myMail.Server & "<br>")
Response.Write("myMail.Mailbox= " & myMail.Mailbox & "<br>")
Response.Write("myMail.Recipient= " & myMail.Recipient & "<br>")
Response.Write("myMail.Subject= " & myMail.Subject & "<br>")
Response.Write("myMail.Text= " & myMail.Text & "<br>")
myMail.Send
set myMail = Nothing
Response.Write("Message sent! Check your inbox.<br>")
%>
</BODY>
</HTML> Installing either Outlook 8.01 or later or installing the Exchange Client with the typical setup solves this problem.CDOMail error '800a01ad'
ActiveX component can't create object.
For additional information about Collaboration Data Objects versus Active
Messaging, please see the following article in the Microsoft Knowledge
Base:
ARTICLE-ID: <LINK TYPE="ARTICLE" VALUE="Q176916">Q176916</LINK>
TITLE : INFO: Active Messaging and Collaboration Data Objects (CDO)
Additional query words: ActMsg CDO Active Messaging Collaboration Data
Keywords: kbASP100 kbCDO110 kbCDO120 kbCDO121 kbMsg kbVBp500 kbVisID100 kbGrpDSMsg
Issue Type: kbhowto
Technology: kbVisIDsearch kbVBSearch kbAudDeveloper kbCDOsearch kbASPsearch kbZNotKeyword6 kbExchangeSearch kbZNotKeyword2 kbVB500Search kbVB500 kbCDO110 kbCDO120 kbCDO121 kbVisID100