[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Script to send confirmation e-mail not working

Posted on 2007-03-29
6
Medium Priority
?
1,073 Views
Last Modified: 2012-05-05
I am using the following script which I got off the internet to send a confirmation e-mail to clients after they have filled in my form.  The problem is that though the script report no errors the e-mails are not received and may well not be sent.  Is there someway I can tell whether the e-mails are at least sent?  What could the problem possibly be?

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Const cdoSendUsingExchange = 3

Const cdoAnonymous = 0
Const cdoBasic = 1
Const cdoNTLM = 2

'Sends an email To aTo email address, with Subject And TextBody.
'The email is In text format.
'Lets you specify BCC adresses, Attachments, smtp server And Sender email address

  on error resume Next

  Dim Message 'As New CDO.Message '(New - For VBA)
 
  'Create CDO message object
  Set Message = CreateObject("CDO.Message")

  'Set configuration fields.
  With Message.Configuration.Fields
    'Original sender email address
    .Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "myemail@yahoo.com"

    'SMTP settings - without authentication, using standard port 25 on host smtp
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.btl.net"

    'SMTP Authentication
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous

    .Update
  End With

  'Set other message fields.
  With Message
    'From, To, Subject And Body are required.
    .From = "myemail@yahoo.com"
    .To = "myemail@yahoo.com"
    .Subject = "Land Registry Application re Parcel " + request.form("PARCELNO") + "in Reg. Section " + request.form("REG_SECTION")

    'Set TextBody property If you want To send the email As plain text
    .TextBody = "This is to confirm receipt of your application(s)."

    'Set HTMLBody  property If you want To send the email As an HTML formatted
    '.HTMLBody = TextBody

    'Blind copy And attachments are optional.
    'If Len(BCC)>0 Then .BCC = BCC
    'If Len(Files)>0 Then .AddAttachment Files
   
    'Send the email
       response.write("before sending")
    .Send
    response.write("after sending")
  End With

  'Returns zero If succesfull. Error code otherwise
  SendMailByCDO = Err.Number
0
Comment
Question by:desmondg
[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
6 Comments
 

Author Comment

by:desmondg
ID: 18820429
I put a response.write err.description and gets the error
"The transport failed to connect to the server."  Any ideas anyone.
0
 
LVL 6

Expert Comment

by:DocGyver
ID: 18867299
Next thing I'd try is to attemt to telnet to port 25 on the smtp.btl.net machine from the machine where the code has to run.  If you get a response then send the QUIT command to disconnect.  Doing so will at least see if you can connect and issue a simple command.

If that works then you should try to send an email manually. To do this telnet to port 25 again and issue the following commands changing for appropriate email addresses in case it works:

telnet smtp.btl.net 25
HELO localhost
MAIL FROM: my@mydomain.tld
RCPT TO: guytosendto@his.domain.tld
DATA
put some things to send here
and finish with a line with a single dot (.) on a line by itself
.
QUIT

You may not have to issue the QUIT depending on how the server is configured.  Let me know what results you get with that.  Then we can diagnose the CDO stuff in your VB code.
0
 

Author Comment

by:desmondg
ID: 19190006
After we changed our DSL provider I was surprised to find that e-mails were filling my in-box from this application.  

I have tried DocGyver's experiments since and was able to send e-mails using telnet.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 20634014
PAQed with points refunded (250)

Computer101
EE Admin
0
 

Expert Comment

by:Trindaz
ID: 21843392
I know points have been refunded already but...

Is your SMTP server configured to allow for anonymous sending of emails? This might explain why email sending works from your email client, but not from the script, and would explain why you can't connect to the server.

The line specifying anonymous sending copied below (change to what I'm not exactly sure)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous

Open in new window

0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

649 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