Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending an Email

Status
Not open for further replies.

kliz0328

Programmer
Nov 7, 2005
138
US
I know I might get bashed, but I went through the FAQ's and eveything and have tried tons of different code, but I am trying to send an email and below is the code that I am using, and it executes, but I never receive an email. ANy suggestions?

Code:
<%
If Not(IsEmpty(Request.Form)) Then

Dim myMail

Set myMail=CreateObject("CDO.Message")
myMail.Subject=Request.Form("Subject")
myMail.From=Request.Form("Email")
myMail.To="jlizzi@carletoninc.com"
myMail.TextBody="From: " & Request.Form("FName") & " " & Request.Form("LName") & vbcrlf & Request.Form("content")
myMail.Send
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")=2[/URL]
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] _
="smtp.carletonasptest.com"
'Server port
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] _
=25
myMail.Configuration.Fields.Update
set myMail=nothing


End If
%>
 
No luck yet here is the last piece of code that I tried, but still to no avail. Do you think that maybe my username and password are off, would the code still execute without error, but just not send? I know my smtp is right, b/c this worked when I did it in .Net.

Code:
  Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
  Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
  Const cdoAnonymous = 0 'Do not authenticate
  Const cdoBasic = 1 'basic (clear-text) authentication
  Const cdoNTLM = 2 'NTLM
On ERROR Resume Next
  if sCC = "" then sCC = Null
  if sBCC = "" then sBCC = Null
  Set objMessage = CreateObject("CDO.Message")
  objMessage.Subject = sSubject
  objMessage.from = sFrom
  objMessage.To = sTo
  if NOT sCC = null then objMessage.CC = sCC
  if NOT sBCC = null then objMessage.BCC = sBCC
  if instr(1,sMessage,"<html>") < 5 then
objMessage.HTMLBody = sMessage
  else
    objMessage.TextBody = sMessage
  end if
  if not isEmpty(Attachments) then
    objMessage.Fields.Item("urn:schemas:mailheader:Content-Type") = "multipart/mixed"
    objMessage.MimeFormatted = true
    aAttach = split(Attachments,",")
for each fle in aAttach
  if not isEmpty(fle) then objMessage.addAttachment("file://" & fle)
next
  end if
'provide the configuration information for the remote SMTP server.
  objMessage.Configuration.Fields.Item _
    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
'Name or IP of Remote SMTP Server
  objMessage.Configuration.Fields.Item _
    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "[URL unfurl="true"]WWW.CarletonInc.COM"[/URL]
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
  objMessage.Configuration.Fields.Item _
    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")[/URL] = cdoBasic
'Your UserID on the SMTP server
  objMessage.Configuration.Fields.Item _
    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername")[/URL] = "administrator"
'Your password on the SMTP server
  objMessage.Configuration.Fields.Item _
    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword")[/URL] = "abcABC123"
'Server port (typically 25)
  objMessage.Configuration.Fields.Item _
    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
'Use SSL for the connection (False or True)
  objMessage.Configuration.Fields.Item _
    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpusessl")[/URL] = False
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
  objMessage.Configuration.Fields.Item _
    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 60
  objMessage.Configuration.Fields.Update
'End remote SMTP server configuration
  objMessage.Send
  if err.number > 0 then
    response.write err.number & err.message
  end if
  SendEmail =  err.number
 
There are a couple of things that would make it execute with no errors but not send the email. Usually that will be caused by incorrect setup at the SMTP server, but if you've sent email through it already that must not be the problem. I would try using an incorrect email/pass to verify wether or not it will give you an error for that. I think it will not. It is definitely worth checking.

Travis Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top