Solved

CDO .Send Authentication

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
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).

864 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now