?
Solved

CDO .Send Authentication

Posted on 2004-09-23
4
Medium Priority
?
1,640 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
  • 2
3 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

829 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