• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 543
  • Last Modified:

CDOSYS and MS Exchange

I'm trying to send an email using CDOSYS on an IIS server with MS Exchange installed.  I keep getting "Access is denied" when I call the message.Send method.  I did discover that to fix this I would need to set my application to run in the ExchangeApplicationPool, but I can't seem to do that.  On the properties, Home Directory tab for the site, I have Application Protection instead of Application Pooling.

Any ideas?
0
netsmithcentral
Asked:
netsmithcentral
  • 4
  • 2
1 Solution
 
Irwin SantosComputer Integration SpecialistCommented:
do you have username & password incorporated?

can you post your code please?
0
 
netsmithcentralAuthor Commented:
<%@ language="javascript" %>
<%
var message = Server.CreateObject('CDO.Message');

message.Subject = 'Your website statistics report for site: one';
message.From = 'noreply@mydomain.com';
message.To = 'client@domain.com';
message.TextBody = 'So far, you have had ' + cnt + ' visits to your site';
message.Send();
%>

I don't have a username and password on the asp page that's on.
0
 
Irwin SantosComputer Integration SpecialistCommented:
Here is an "ap_sajith" solution from PAQ (BTW, are you running JAVA or VB?)
----------------------------------------------------------
CDOSYS:

' ** SUBROUTINE TO SEND EMAIL USING CDOSYS **

'**USAGE **
'strMailBody="<Font Color=Red><B>Test HTML String</B></Font>"
'CALL SendMailCDOSYS("a@b.com","c@d.com","test",strMailBody,True,"mail.yahoo.com","admin","password")

Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer,sUid,sPwd)
On Error Resume Next
Dim objCDOConf,objCDOSYS
' ** CREATE THE E-MAIL SERVER OBJECT **
Set objCDOSYS = Server.CreateObject("CDO.Message")
Set objCDOConf = Server.CreateObject ("CDO.Configuration")

' ** SET AND UPDATE FIELDS PROPERTIES **
With objCDOConf    
     ' ** OUT GOING SMTP SERVER **
     .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
     ' ** SMTP PORT **
     .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
     ' ** CDO PORT **
     .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ' cdoSendUsingPort
     ' ** TIMEOUT **
     .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
     ' Check if SMTP Authentication is required
     If sUid<>"" Then
          ' ** AUTHENTICATION MECHANISM **
          .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'cdoBasic
          ' The username for authenticating to an SMTP server
          .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = sUid
          ' The password used to authenticate to an SMTP server
          .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = sPwd
     End If
     .Fields.Update
End With

' ** UPDATE THE CDOSYS CONFIGURATION **
Set objCDOSYS.Configuration = objCDOConf

With objCDOSYS    
     ' ** WHO THE E-MAIL IS FROM **
     .From = strFrom

     ' ** WHO THE E-MAIL IS SENT TO **
     .To = strTo

     ' ** THE SUBJECT OF THE E-MAIL **
     .Subject = strSubject

     ' ** SET THE E-MAIL BODY FORMAT (HTMLBody=HTML TextBody=Plain) **
     If blnHTML = True Then
          .HTMLBody = strMailBody
     Else
          .TextBody = strMailBody
     End If

     ' ** SEND THE E-MAIL **
     .Send
End with                    

' ** CLOSE THE SERVER MAIL OBJECT **
Set objCDOSYS = Nothing
End Sub
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
netsmithcentralAuthor Commented:
I'm using JavaScript, and while that solution works, it requires the use of an outside SMTP server.  Shouldn't I be able to send this from my server?
0
 
Irwin SantosComputer Integration SpecialistCommented:
yes..but you need to be authenticated and that is the key UNLESS you use your upstream provider
0
 
Irwin SantosComputer Integration SpecialistCommented:
cool. thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now