Solved

CDO .Send Authentication

Posted on 2004-09-23
4
1,629 Views
Last Modified: 2008-03-10
joeposter649 had helped me stop pulling my hair out yesterday with the cdo.bodyformat issue and i was succesfulyl sending emails in html format.

Once again I will list my included sendmail2k.inc file which is included in the .asp page.

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Library" -->
<%
Function SendMail(inTo, inFrom, inSubject, inBody)
Const cdoSendUsingMethod        =       "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort          = 2
Const cdoSMTPServer             =       "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort         =       "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout  =       "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate       =       "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic                  = 1
Const cdoSendUserName           =       "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword           =       "http://schemas.microsoft.com/cdo/configuration/sendpassword"

Dim objConfig  ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields     ' As ADODB.Fields

' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
      .Item(cdoSendUsingMethod)       = cdoSendUsingPort
      .Item(cdoSMTPServer)            = "SERVERNAME"
      .Item(cdoSMTPServerPort)        = 25
      .Item(cdoSMTPConnectionTimeout) = 10
      .Item(cdoSMTPAuthenticate)      = cdoBasic
      .Item(cdoSendUserName)          = "USERACCOUNT"
      .Item(cdoSendPassword)          = "PASSWORD"
      .Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig

With objMessage
      .To       = inTo
      .From     = inFrom
      .Subject  = inSubject
      .HTMLBody = inBody
      .Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing

End Function

Function SendHTMLMail(inTo, inFrom, inSubject, inBody)
Const cdoSendUsingMethod        =       "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort          = 2
Const cdoSMTPServer             =       "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort         =       "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout  =       "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate       =       "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic                  = 1
Const cdoSendUserName           =       "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword           =       "http://schemas.microsoft.com/cdo/configuration/sendpassword"

Dim objConfig  ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields     ' As ADODB.Fields

' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
      .Item(cdoSendUsingMethod)       = cdoSendUsingPort
      .Item(cdoSMTPServer)            = "SERVERNAME"
      .Item(cdoSMTPServerPort)        = 25
      .Item(cdoSMTPConnectionTimeout) = 10
      .Item(cdoSendUserName)          = "USERACCOUNTr"
      .Item(cdoSendPassword)          = "PASSWORD"
      .Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig

With objMessage
      .To       = inTo
      .From     = inFrom
      .Subject  = inSubject
      .HTMLBody = inBody
      .Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing

End Function
%>

error '8004020e'
%:\SITE\CONTACTUS\../tools/SendMail2k.inc, line 89

Line 89 is .Send

This worked yesterday. I recieved the html email when I tested it several times.
I am almost convinced that this is a permissions issue but I am not sure. The site resides on one server and the smtp server is on the other server with relay permissions granted both by IP and DNS Name.

I am at a standstill and once again, (this is getting embarassing) I am looking to my fellow ee gurus for assistance.
0
Comment
Question by:nurv-x
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:nurv-x
ID: 12135860
Ok, I've stripped completley any calls from a db in the html of the asp page.

this is the only html

(asp included)

If Request("bAdd") = "1" Then
    strSQL = "INSERT INTO tblContactForm (NAME, TITLE, ORGANIZATION, ADDRESS, CITY, STATE_PROV, POSTALCODE, COUNTRY, PHONENUMBER, ADD_COMMENTS, EMAIL, FDP, FP, FS, IOR, JOBTITLE, BEST_JOB_FUNCTION, EMPLOYEES, JOB_INDUSTRY, SCANNER) VALUES ('" & Replace(Request("txtNAME"), "'", "''") & "', '" & Replace(Request("txtTITLE"), "'", "''") & "', '" & Replace(Request("txtORGANIZATION"), "'", "''") & "', '" & Replace(Request("txtADDRESS"), "'", "''") & "', '" & Replace(Request("txtCITY"), "'", "''") & "', '" & Replace(Request("txtSTATE_PROV"), "'", "''") & "', '" & Replace(Request("txtPOSTALCODE"), "'", "''") & "', '" & Replace(Request("txtCOUNTRY"), "'", "''") & "', '" & Replace(Request("txtPHONENUMBER"), "'", "''") & "', '" & Replace(Request("txtADD_COMMENTS"), "'", "''") & "', '" & Replace(Request("txtEMAIL"), "'", "''") & "', '" & Replace(Request("txtFDP"), "'", "''") & "', '" & Replace(Request("txtFP"), "'", "''") & "', '" & Replace(Request("txtFS"), "'", "''") & "', '" & Replace(Request("txtIOR"), "'", "''") & "', '" & Replace(Request("txtJOBTITLE"), "'", "''") & "', '" & Replace(Request("txtBEST_JOB_FUNCTION"), "'", "''") & "', '" & Replace(Request("txtEMPLOYEES"), "'", "''") & "', '" & Replace(Request("txtJOB_INDUSTRY"), "'", "''") & "',  '" & Replace(Request("txtSCANNER"), "'", "''") & "')"
      'response.write(strSQL)
      dbConn.Execute(strSQL)
      'response.write(strSQL)
      strSQL = "SELECT TOP 1 * FROM qryContactForm WHERE NAME='" & Request("txtNAME") & "' AND TITLE='" & Request("txtTITLE") & "' AND ORGANIZATION='" & Request("txtORGANIZATION") & "' AND FP='" & Request("txtFP") & "' AND FS='" & Request("txtFS") & "' AND FDP='" & Request("txtFDP") & "' AND IOR='" & Request("txtIOR") & "' AND JOB_INDUSTRY='" & Request("txtJOB_INDUSTRY") & "' AND ADD_COMMENTS='" & Request("txtADD_COMMENTS") & "' AND ADDRESS='" & Request("txtADDRESS") & "' AND CITY='" & Request("txtCITY") & "' AND STATE_PROV='" & Request("txtSTATE_PROV") & "' AND POSTALCODE='" & Request("txtPOSTALCODE") & "' AND COUNTRY='" & Request("txtCOUNTRY") & "' AND PHONENUMBER='" & Request("txtPHONENUMBER") & "' AND JOBTITLE='" & Request("txtJOBTITLE") & "' AND EMAIL='" & Request("txtEMAIL") & "' AND EMPLOYEES='" & Request("txtEMPLOYEES") & "' AND BEST_JOB_FUNCTION='" & Request("txtBEST_JOB_FUNCTION") & "' AND SCANNER='" & Request("txtSCANNER") & "'"                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
       'response.write(strSQL)
     Set rsInfo = dbConn.Execute(strSQL)
       response.write(strSQL)
     
     tmpBody =  "<html><link rel=""stylesheet"" href=""http://www.clearview-printing.com/tools/cpc.css"" type=""text/css"">" & _
               "<body><table width=""575"" cellpadding=""0"" cellspacing=""0"" border=""1"" align=""center""><tr><td width=""575"" height=""112"" background=""../images/email.gif""></td>" & _
               "</tr></table></body></html>"                     
     SendHTMLMail "info@clearview-printing.com", "CLEARVIEW PRINTING CO., INC.<postmaster@clearview-printing.com>", "CPC WEB REQUEST FORM", tmpBody      
      rsInfo.Close
End IF %>

So basically all I am ending is a tbale with an image right now. HAS to be a permissions issue.
0
 

Author Comment

by:nurv-x
ID: 12138304
I made a few editions to my inclusion file (a lot actually) and it's perfect!

If anyone else has this problem. Feel free to grab this:

<%
Function SendHTMLMail(inBody)

Const cdoSendUsingMethod = _
"http://schemas.microsoft.com/cdo/configuration/sendusing
Const cdoSendUsingPort = 2
Const cdoSMTPServer = _
"http://schemas.microsoft.com/cdo/configuration/smtpserver
Const cdoSMTPServerPort = _
"http://schemas.microsoft.com/cdo/configuration/smtpserverport
Const cdoSMTPConnectionTimeout = _
"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout
Const cdoSMTPAuthenticate = _
"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
Const cdoBasic = 1
Const cdoSendUserName = _
"http://schemas.microsoft.com/cdo/configuration/sendusername
Const cdoSendPassword = _
"http://schemas.microsoft.com/cdo/configuration/sendpassword

Dim objConfig ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields ' As ADODB.Fields

' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "SMTPserver"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "Authorized User"
.Item(cdoSendPassword) = "UserPass"

.Update
End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
.To = "RECIPIENT <your_recipient@hisdomain.com>"
.From = "SENDER <sender@sendersdomain.com>"
.Subject = "CHANGE ME"
.HTMLBody = inBody
.Send
End With


Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing

End Function
%>

Remebr that this is an inclusive file! In my asp I have <!--#include file="../tools/SendMail3k.inc"--> within the head of my asp file. That being said, notice .HTMLBody method's value is inBody, and inBody is being called within my asp.

CHEERS!
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12471970
PAQed, with points refunded (250)

modulo
Community Support Moderator
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

691 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