?
Solved

CDOSYS and MS Exchange

Posted on 2006-05-26
6
Medium Priority
?
537 Views
Last Modified: 2012-05-05
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
Comment
Question by:netsmithcentral
  • 4
  • 2
6 Comments
 
LVL 30

Expert Comment

by:Irwin Santos
ID: 16773594
do you have username & password incorporated?

can you post your code please?
0
 
LVL 12

Author Comment

by:netsmithcentral
ID: 16773619
<%@ 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
 
LVL 30

Expert Comment

by:Irwin Santos
ID: 16773655
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Author Comment

by:netsmithcentral
ID: 16773813
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
 
LVL 30

Accepted Solution

by:
Irwin Santos earned 1500 total points
ID: 16773901
yes..but you need to be authenticated and that is the key UNLESS you use your upstream provider
0
 
LVL 30

Expert Comment

by:Irwin Santos
ID: 16774332
cool. thank you!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question