Wrox Programmer Forums
|
ASP CDO As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP CDO section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 11th, 2003, 08:12 AM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to raman Send a message via Yahoo to raman
Default CDONTS Receiving mail in ASP

Hi,

I am trying to write an ASP in using CDONTS to receiving mails.

My code:

-----------------------------------------------------------------

<%Option Explicit%><BR><BR>
<wml>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<%On Error Resume Next

' set up email address of sender we are interested in

Dim sEmailFrom
sEmailFrom = "[email protected]"
' get to collection of messages
Dim objSession
'Dim objInbox ' default Inbox or Outbox
'Dim collMessages ' messages in folder

Set objSession = CreateObject("CDONTS.Session")


'count how many messages come from this sender
Dim i
Dim nMessages
nMessages = 0
For i=1 To objInbox.Messages
    'If (lcase(colMessages(i).sender) = lcase(sEmailFrom)) Then
        nMessages = nMessages+1
    'end if
Next

' write main index card
Response.Write "<cardid=" & Chr(34) & "index" & Chr(34) & " title=" & Chr(34) & "Inbox" & Chr(34) & ">" & vbCrLf
Response.Write "<p>" & nMessages & " Messages</p>" & vbCrLf
For i=1 To nMessages
' If (lcase(colMessages(i).Sender) = lcase(sEmailFrom)) Then
' Response.Write (i & " " & colMessages(i).sender)
' End If
Next
Response.Write "</card>" & vbCrLf
    ' write cards with the messages on
For i=1 To colMessages.count
' If (lcase(colMessages(i).Sender) = lcase(sEmailFrom)) Then
        Response.Write "<card id=" & Chr(34) & "mail" & CStr(i)& Chr(34) & " title=" & Chr(34) & "Message Text" & Chr(34) & ">" & vbCrLf
        Response.Write "<p><b>" & colMessages(i).Subject & "</b></p>" & vbCrLf
        Response.Write "<p>" & colMessages(i).Text & "</p>" & vbCrLf
        Response.Write "<p><a href=" & Chr(34) & "#index" & Chr(34)& ">" & "Index</a></p>" & vbCrLf
        Response.Write "</card>" & vbCrLf
' End If
Next
' clean up etc.
objSession.Logoff
Set objSession = Nothing%>
</wml>

---------------------------------------------------------------
what is wrong in this one? Please help to me


Thanks & regards


 
Old March 23rd, 2004, 02:37 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

CHECK THIS CODE MORE USEFUL FOR YOU
'''''''''''''''''''PAGE NAME=contactus.asp'''''''''''''''
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<script language="JavaScript">
<!--
function onSubmit1()
{
if (document.form1.txtContactName.value=="")
{
    alert("Please Enter the Contact Name")
    document.form1.txtContactName.focus()
    return;
}
 if ((document.form1.txtEmail.value == "")&&(document.form1.txtFax.value == "")&&(document.form1.txtTel.value == ""))
  {
    alert("Please enter a value for E mail / Phone / Fax");
     document.form1.txtTel.focus();
    return;
  }



   if (document.form1.txtEmail.value!= "")
  {
 var mail1=document.form1.txtEmail.value;
  var i1 = mail1.indexOf('@');
   var i2 = mail1.lastIndexOf('@');
   var i3 = mail1.indexOf('.');
  if (mail1.length<=5)
  {
  alert("Your E-mail address is too small");
   document.form1.txtEmail.focus();
  return;
   }

    if(i1==-1)
 {
  alert(" E-mail address must have a '@' ");
   document.form1.txtEmail.focus();
 return;
  }

   if (i3+1==mail1.length)
  {
 alert(" E-mail address cannot contain '.' in end");
  document.form1.txtEmail.focus();
  return;
 }

  if(i1!=i2)
{
 alert(" E-mail address cannot contain two '@' signs");
  document.form1.txtEmail.focus();
 return;
  }
}


if (document.form1.txtEmail.value!= "")
{
     var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎà ÃÃ‘Ã’Ã“Ã”Ã•Ã–Ã˜Ã™ÃšÃ›ÃœÃÃžÃŸÃ Ã¡Ã¢Ã£Ã¤Ã¥Ã¦Ã§Ã¨Ã ©ÃªÃ«Ã¬Ã­Ã®Ã¯Ã°Ã±Ã²Ã³Ã´ÃµÃ¶Ã¸Ã¹ÃºÃ»Ã¼Ã½Ã¾012345678 9-_.@";
    var checkStr = document.form1.txtEmail.value;
    var allValid = true;
    for (i = 0;i<checkStr.length;i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0; j < checkOK.length; j++)
        if (ch == checkOK.charAt(j))
            break;
        if (j == checkOK.length)
        {
            allValid = false;
            break;
        }
    }
    if (!allValid)
    {
        alert("Please enter only letter, digit and \"@\" characters in the \"E-mail\" field.");
        document.form1.txtEmail.focus();
        return;
    }

}
if(document.form1.txtEnquire.value=="")
{
    alert("Please Enter the Message");
    document.form1.txtEnquire.focus ();
    return;
}
else
{
document.form1.mode.value="mailit"
document.form1 .action ="contactus.asp"
document.form1 .submit ();
}
}
//-->
</script>
</head>
  <%
    mode=Request("mode")
%>
<body topmargin="0" leftmargin="0" >
<%if mode<>"mailit" then%>
   <form method="post" name="form1">
  <table border="0" width="100%" height="" cellpadding="0" cellspacing="0" bordercolor=red>
  <tr>
    <td width="4%" height="15">&nbsp;</td>
        <td width="16%" height="15" colspan="3" align="center" >
        <table width="100%" border=0 bordercolor=red>
        <td width="33%"></td>
        <td width="33%" align=center><b>Contact us</b> </td>
        <td width="33%" align=right><a href="default.htm"><img border="0" src="images/home.gif" width="44" height="21"></a> </td>
        </table>
        </td>

      <td width="4%" height="15">&nbsp;</td>
    </tr>
     <tr>
      <td width="4%" height="15">&nbsp;</td>
      <td width="16%" height="15" colspan="3" align="center" >&nbsp;</td>
      <td width="4%" height="15">&nbsp;</td>
    </tr>
        <tr>
      <td width="4%" height="15">&nbsp;</td>
      <td width="16%" height="15" colspan="3"></td>
      <td width="4%" height="15">&nbsp;</td>
    </tr>
    <tr>
     <td width="4%" >&nbsp;</td>
      <td width="26%" >Contact Name</td>
      <td width="2%" >:</td>
      <td width="63%" ><input size=35 name="txtContactName" style="border: 1 solid #008000">&nbsp;*</td>
      <td width="4%"></td>
    </tr>
    <tr>
     <td width="4%" >&nbsp;</td>
      <td width="26%" >Company</td>
       <td width="2%" >:</td>
      <td width="63%"><input size=35 name="txtCompany" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >Address </td>
     <td width="2%" >:</td>
      <td width="63%" ><input size=35 name="txtAddress1" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" height="27" >City</td>
      <td width="2%" >:</td>
      <td width="63%" height="27"><input size=35 name="txtAddress2" style="border: 1 solid #008000"></td>
      <td width="4%" height="27">&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >County</td>
       <td width="2%" >:</td>
      <td width="63%" ><input size=35 name="txtAddress3" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >Post Code&nbsp;&nbsp;&nbsp;
            </td>
     <td width="2%" >:</td>
          <td width="63%" ><input size=20 name="txtPostCode" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >Tel</td>
       <td width="2%" >:</td>
      <td width="63%" ><input size=20 name="txtTel" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >Fax</td>
       <td width="2%" >:</td>
      <td width="63%" ><input size=20 name="txtFax" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >E mail</td>
      <td width="2%" >:</td>
     <td width="63%" ><input size=35 name="txtEmail" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
     <td width="4%" >&nbsp;</td>
      <td width="26%" >Enquiry Details</td>
      <td width="2%" >:</td>
      <td width="63%" valign="top"><TEXTAREA name=txtEnquire rows="6" cols="30" style="border: 1 solid #008000"></TEXTAREA>&nbsp;*</td>
      <td width="4%" >&nbsp;</td>
    </tr>
     <tr>
     <td width="4%" height="" >&nbsp;</td>
      <td width="26%" height="" >&nbsp;</td>
       <td width="2%" height="">&nbsp;</td>
      <td width="63%" height="">&nbsp;</td>
      <td width="4%" height="">&nbsp;</td>
    </tr>
    <tr>
      <td width="63%" height="" colspan="5" align="center" colspan="2">
     <a href="javascript:onSubmit1()"><IMG height=23 src="images/btnsubmit.GIF" width=78 border=0></a>&nbsp; </td>
    </tr>

    <tr>
        <td width="4%" height="" >&nbsp;</td>
         <td width="16%" height="" >&nbsp;</td>
          <td width="12%" height="">&nbsp;</td>
         <td width="63%" height="">&nbsp;</td>
         <td width="4%" height="">&nbsp;</td>
       </tr>
    <tr>
        <td width="4%" height="" ></td>
         <td width="91%" height="" colspan="3"></td>
         <td width="4%" height=""></td>
       </tr>

       <tr>
    <td width="4%" height></td>
    <td width="92%" height colspan=3></td>
    <td width="4%" height></td>
  </tr>
           <tr>
        <td width="4%" height="" >&nbsp;</td>
         <td width="16%" height="" >&nbsp;</td>
          <td width="12%" height="">&nbsp;</td>
         <td width="63%" height="">&nbsp;</td>
         <td width="4%" height="">&nbsp;</td>
       </tr>
  </table>
 <input class="smalltxt5" name="mode" type="hidden">
 </form>
 <%end if%>
  <%
if mode="mailit" then
    ContactName=Request("txtContactName")
    Company=Request("txtCompany")
    Address1=Request("txtAddress1")
    Address2=Request("txtAddress2")
    Address3=Request("txtAddress3")
    PostCode=Request("txtPostCode")
    Tel=Request("txtTel")
    Fax=Request("txtFax")
    Email=Request("txtEmail")
    Enquire=Request("txtEnquire")
    path=Request("HTTP_REFERER")
str=""
str=str+"<table border='0'bordercolor='red' align='center' width='90%' height='' cellpadding='0' cellspacing='0'>"
str=str+"<tr>"
str=str+"<td width='21%' align='center' colspan='3' height='23' ><b>Your mail has been send successfully</b></td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' align='center' colspan='3' height='23' ><b>Contact Us</b></td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Contact Name</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&ContactName&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"

str=str+"<tr>"
str=str+"<td width='21%' height='23'>Company</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Company&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Address</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Address1&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='27'>City</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='27'>"&Address2&"</td>"
str=str+"<td width='4%' height='27'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>County</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Address3&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Post Code&nbsp;&nbsp;&nbsp; </td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&PostCode&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Tel</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Tel&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Fax</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Fax&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>E mail</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Email&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Enquiry Details</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Enquire&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr></table>"



    set mail_Obg=createObject("CDONTS.newmail")
    if Email="" then
    mail_Obg.From="[email protected]"
    else
    mail_Obg.From=Email
    end if
    mail_Obg.To ="[email protected]"
    strtobcc="[email protected];[email protected]"
    mail_Obg.Subject = "Enquiry"
    mail_Obg.BodyFormat=0
    mail_Obg.MailFormat=0
    mail_Obg.Body =str
    mail_Obg.Bcc = strtobcc
    mail_Obg.Importance=2
    mail_Obg.Send
    'Response.Write str
    set mail_Obg=nothing
    'msg="Sorry,unable to send mail!"
Response.Write str
end if
%>
</body>

</html>


surendran
(Anything is Possible)
 
Old March 23rd, 2004, 02:57 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:CHECK THIS CODE MORE USEFUL FOR YOU
More useful? I think the original poster asked for code to retrieve e-mail, while the code you posted is used to send e-mail....

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
not receiving any mail from new topics.. gbianchi Forum and Wrox.com Feedback 2 April 16th, 2007 07:34 AM
CDO/CDONTS: Receiving mail delivery confirmation antalas Classic ASP Professional 0 February 21st, 2006 03:43 PM
Receiving mail rajanikrishna Classic ASP Basics 11 November 24th, 2004 05:06 AM
CDONTS ASP Mail Code egerdj Classic ASP Basics 0 February 19th, 2004 10:25 PM
Sending both text mail and HTML mail - CDONTS madhukp Classic ASP Basics 1 October 8th, 2003 01:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.