Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CDO .Send Authentication

Posted on 2004-09-23
4
Medium Priority
?
1,636 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

636 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