Solved

CDO .Send Authentication

Posted on 2004-09-23
4
1,627 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS Question.. 3 104
How to replace a token in a string with square brackets? 2 101
What does GoogleTagMgr javascripts below do 5 86
How to build a web site 17 98
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

732 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