Solved

Set Mail=CreateObject("CDO.Message")

Posted on 2010-11-16
3
1,661 Views
Last Modified: 2012-05-10
Hi Experts,

I have the following page.http://www.caf-fca.org/en/contact/

It was hosted on a windows 2000 Server and I was able to receive emails.  The code is working but I'M NOT RECEIVING ANY EMAILS... Should I need to installed anything on the server.

It's  Windows 2008 Servers.  I've have the code CDO.MESSAGE to send an online forms.

 
*******************************************

// Front CODE 

*******************************************



<form method="post" action="../who_we_are/thankyou.asp" onSubmit="return checkForm(this);">

<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">

 <tr bgcolor="#4775a3">

   <td colspan="2"><div align="left"><strong><font color="#FFFFFF" size="+1">*</font> <font color="#FFFFFF"> = Required field</font></strong></div></td>

 </tr>

 <tr bgcolor="#ccd9e5">

   <td width="36%" class="byline"><div align="right"> Send this e-mail to:</div></td>

   <td width="64%" class="byline"><select size="1" name="to" class="formfield">

                <option selected value="info@caf-fca.org">General Enquiries</option>

                <option value="margo_royce@caf-fca.org">Marketing, Communications & Media Enquiries</option>

 			    <option value="margo_royce@caf-fca.org">CAF-FCA Conference</option>

                <option value="elie_azzi@caf-fca.org">Information Technology</option>

                <option value="emily_arrowsmith@caf-fca.org">Programs & Corporate Development</option>						

              </select></td>

 </tr>

 

 <tr bgcolor="#DDDDDD">

   <td class="byline"><div align="right"> Attention: </div></td>

   <td><input type="text" name="attn" size="51">

   <INPUT TYPE="HIDDEN" name="note" value="Email sent from CAF-FCA Web site - http://www.caf-fca.org/english/contact.asp"></td>

 </tr>

 

 <tr bgcolor="#ccd9e5">

   <td class="byline"><div align="right"> Preferred contact method:</div></td>

   <td><select size="1" name="method" class="formfield">

                <option selected value="email">by e-mail</option>

                <option value="phone">by telephone</option>

                <option value="do not contact me">do not contact me</option>

              </select></td>

 </tr>

 

 <tr bgcolor="#DDDDDD">

   <td class="byline"><div align="right">Your name: </div></td>

   <td><select name="salutation" size="1" id="MyContactInfo_PrefixList" size="15">

     <option selected>Select One</option>

     <option value="Mr.">Mr.</option>

     <option value="Mrs.">Mrs.</option>

     <option value="Ms.">Ms.</option>

     <option value="Dr.">Dr.</option>

    </select><input type="text" name="name" size="35"></td>

 </tr>

 

<tr bgcolor="#ccd9e5">

   <td width="36%" class="byline"><div align="right"><font size="+1" color="#FF0000"><strong>*</strong></font> Your Email:</div></td>

   <td width="64%"><input type="text" name="From" size="51"></td>

 </tr> 



<tr bgcolor="#DDDDDD">

   <td class="byline"><div align="right">Your telephone: </div></td>

   <td>( <input name="phone1" id="phone1" value="" size="3" maxlength="3"> 

        )  

        <input name="phone2" id="phone2" value="" size="3" maxlength="3"> 

        -  

        <input name="phone3" id="phone3" value="" size="4" maxlength="4"> 

        Ext.:

          [ <input name="phone4" id="phone4" value="" size="6" maxlength="6"> 

          ]  </td>

 </tr>





<tr bgcolor="#ccd9e5">

   <td class="byline" valign="top"><div align="right"> What can we do for you?</div></td>

   <td><textarea cols="40" rows="5" name="message"></textarea></td>

 </tr>

  <tr bgcolor="#DDDDDD">

   <td colspan="2" class="byline" align="center">

 <input type="submit" value="Submit" name="SUBMIT">

 <input type="reset" value="Clear" name="RESET">

 </td></tr>

</table>

</form>







*******************************************

// BACKEND CODE thankyou.asp

*******************************************

<%



Dim from, sendto, subject, attn, body, name, phone, method

Dim strSQL



Set from = Request.Form("from")

Set subject = Request.Form("subject")

Set sendto = Request.Form("to")

Set attn = Request.Form("attn")

Set body = Request.Form("message")

Set salutation = Request.Form("salutation")

Set name = Request.Form("name")

Set phone1 = Request.Form("phone1")

Set phone2 = Request.Form("phone2")

Set phone3 = Request.Form("phone3")

Set phone4 = Request.Form("phone4")

Set method = Request.Form("method")



body =	"From: " & salutation & " " & name & chr(10) & chr(13) & _

		"Preferred contact method: " & method & chr(10) & chr(13) & _

		"E-mail: " & From & chr(13) & _

		"Phone: " & "(" & phone1 & ")" & " " & phone2 & "-" & phone3 &  " Ext. " & phone4 & chr(10) & chr(13) & _ 

		"Message:" & chr(13) & body & chr(10) & chr(13) & _

		"--------------------------------------------------------------" & chr(13) & _

		"E-mail sent via CAF-FCA web forms.  Email has been sent to : " & sendto & " - " &  now() & chr(10) & chr(13) 





'--------------July 28 2004 Sending email using CDONT --------------------

	

	Set Mail=CreateObject("CDO.Message")

Mail.Subject=attn

Mail.From = name & " (" & From & ")"

Mail.To=sendTo

Mail.TextBody=body			



On Error Resume Next	

	Mail.Send 	

	set Mail = Nothing



'--------------------------------------------------------------------------



'On Error Resume Next

'Mail.Send

If Err <> 0 Then

   Response.Write "Error encountered: " & Err.Description

else

	Response.Write "Thank you.<br><br>Your email has been sent. Please allow at least 24 hours for a response if you requested one."

End If

%>

Open in new window

0
Comment
Question by:elieazzi
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
ahdfx earned 500 total points
Comment Utility
First off, does the server have SMTP installed?  Do you have a mail server onsite?  You may need to configure relay on the server to allow emails to be sent by itself.

Here is my ASP classic Email CDO sub-routine.  You can modify it and try it, but it does require auth.

Public Sub SendEMail(ByVal argFromAddress, ByVal argToAddress, ByVal argSubject, ByVal argBody)
      Dim objMail
      
      On Error Resume Next  ' Fail quietly ...

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)            = "192.168.1.20"
     .Item(cdoSMTPServerPort)        = 25
     .Item(cdoSMTPConnectionTimeout) = 10
     .Item(cdoSMTPAuthenticate)      = cdoBasic
     .Item(cdoSendUserName)          = "username"
     .Item(cdoSendPassword)          = "pasword"

     .Update
End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
     .To       = argToAddress
     .From     = argFromAddress
     .Subject  = argSubject
     .HTMLBody = argBody & " " & Now()
     .Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing

End Sub
0
 

Author Comment

by:elieazzi
Comment Utility
Hi Expert,

Please advice, What I should do I've copied the code for your to test... please advice
http://www.caf-fca.org/en/reports/cf_elie.asp
<%

Public Sub SendEMail(ByVal argFromAddress, ByVal argToAddress, ByVal argSubject, ByVal argBody)

      Dim objMail

      

      On Error Resume Next  ' Fail quietly ...



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)            = "192.168.1.20"

     .Item(cdoSMTPServerPort)        = 25

     .Item(cdoSMTPConnectionTimeout) = 10

     .Item(cdoSMTPAuthenticate)      = cdoBasic

     .Item(cdoSendUserName)          = "username"

     .Item(cdoSendPassword)          = "pasword"



     .Update

End With



Set objMessage = Server.CreateObject("CDO.Message")



Set objMessage.Configuration = objConfig



With objMessage

     .To       = argToAddress

     .From     = argFromAddress

     .Subject  = argSubject

     .HTMLBody = argBody & " " & Now() 

     .Send

End With



Set Fields = Nothing

Set objMessage = Nothing

Set objConfig = Nothing



End Sub 

%>

Open in new window

0
 

Author Closing Comment

by:elieazzi
Comment Utility
tx
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I was supporting a handful of Windows 2008 (non-R2) 2 node clusters with shared quorum disks. Some had SQL 2008 installed and some were just a vendor application that we supported. For the purposes of this article it doesn’t really matter which so w…
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

728 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

9 Experts available now in Live!

Get 1:1 Help Now