Link to home
Start Free TrialLog in
Avatar of johnhardy
johnhardyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Jmail to cdosys

Hello
I have a page using jmail where when some buttons are clicked the user is directed to other pages on another site.
When this happens an email is sent to notify the occourance.

The page is working correctly but I have to change to a server which does not have jmail installed.

I need to convert my jmail code to cdosys and wonder if some one can show me how this can be done please?

I am attaching the present code below.
Many Thanks

John

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' wrapper so email will only be sent when submit button is pressed
'If CStr(Request.Form("Submit")) <> "" Then
Set MailObj = Server.CreateObject("JMail.SMTPMail")
MailObj.ServerAddress=("localhost")
MailObj.Sender = "info@xxxx.com"
MailObj.AddRecipientCC "info@yyyy.co.uk"
MailObj.Priority = 3
MailObj.Subject = "Affiliate visit "
'MailObj.BodyFormat = 0 
'MailObj.MailFormat = 0 

HTML = HTML & "<html>" 
HTML = HTML & "<head>" 
HTML = HTML & "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">"
HTML = HTML & "<title>Insurance affiliate visit:</title>" 
HTML = HTML & "<style> *,body,table,tr,td" 
HTML = HTML & "{font-family:verdana;font-size:10px;}"
HTML = HTML & "</style>"
HTML = HTML & "</head>" 
HTML = HTML & "<body>" 
HTML = HTML & "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"">"
HTML = HTML & "<tr valign=top>"
HTML = HTML & "<td>"
HTML = HTML & "</td>"
HTML = HTML & "</tr>"
HTML = HTML & "</table>"

HTML = HTML & "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"">"
HTML = HTML & "<tr>" 
HTML = HTML & "<td ><b>Affiliate visit</b>"&" Date "& FormatDateTime(Now(),0)&""&"</td>"
HTML = HTML & "<td>&nbsp;</td>"
HTML = HTML & "</tr>" 

HTML = HTML & "</table>"
HTML = HTML & "</body>" 
HTML = HTML & "</html>"

MailObj.HTMLBody = HTML
MailObj.Execute
Set MailObj = Nothing

'End If
%>

Open in new window

Avatar of pateljitu
pateljitu
Flag of Canada image

Please try code as provided:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' wrapper so email will only be sent when submit button is pressed
'If CStr(Request.Form("Submit")) <> "" Then
''Set MailObj = Server.CreateObject("JMail.SMTPMail")
''MailObj.ServerAddress=("localhost")
''MailObj.Sender = "info@xxxx.com"
''MailObj.AddRecipientCC "info@yyyy.co.uk"
''MailObj.Priority = 3
''MailObj.Subject = "Affiliate visit "
'MailObj.BodyFormat = 0 
'MailObj.MailFormat = 0 

Dim CDOMessage, CDOConfiguration
Set CDOConfiguration = CreateObject("CDO.Configuration")
With CDOConfiguration.Fields
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = SMTPUserName 'If you configured SMTP to send email using Username and Password
    .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SMTPPassword 'If you configured SMTP to send email using Username and Password
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'cdoBasic
	.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'cdoSendUsingPort
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

	.Update
End With


HTML = HTML & "<html>" 
HTML = HTML & "<head>" 
HTML = HTML & "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">"
HTML = HTML & "<title>Insurance affiliate visit:</title>" 
HTML = HTML & "<style> *,body,table,tr,td" 
HTML = HTML & "{font-family:verdana;font-size:10px;}"
HTML = HTML & "</style>"
HTML = HTML & "</head>" 
HTML = HTML & "<body>" 
HTML = HTML & "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"">"
HTML = HTML & "<tr valign=top>"
HTML = HTML & "<td>"
HTML = HTML & "</td>"
HTML = HTML & "</tr>"
HTML = HTML & "</table>"

HTML = HTML & "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"">"
HTML = HTML & "<tr>" 
HTML = HTML & "<td ><b>Affiliate visit</b>"&" Date "& FormatDateTime(Now(),0)&""&"</td>"
HTML = HTML & "<td>&nbsp;</td>"
HTML = HTML & "</tr>" 

HTML = HTML & "</table>"
HTML = HTML & "</body>" 
HTML = HTML & "</html>"


Set CDOMessage = CreateObject("CDO.Message")
	With CDOMessage

		Set .Configuration = CDOConfiguration

		.From = "info@xxxx.com"
		.To = "info@yyyy.co.uk"
		.Subject = "Affiliate visit "
		.HtmlBody = HTML
        .Send
	End With
Set CDOMessage = Nothing
Set CDOConfiguration = Nothing

'MailObj.HTMLBody = HTML
'MailObj.Execute
'Set MailObj = Nothing

'End If
%>
                                  

Open in new window

Avatar of johnhardy

ASKER

Many thanks pateljitu

I am getting the error

(0x8004020F)
The event class for this subscription is in an invalid partition
/TMPdkrxkdjch1.asp, line 64
Error you mean there is SMTP configuration problem, please refer to this article

http://classicasp.aspfaq.com/email/why-does-cdo-message-give-me-8004020f-errors.html

Also can you please update code on line 21 to try again:
Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
Changing line 21 caused the email to be sent! Thank you.

I had not included the full code which includes the button to send the user to the new site.
At the moment the email is sent as soon as the page open.

I need it to send when  button is clicked

I attach the page code including two buttons.

I apologise for not sending the fuller code earlier>

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' wrapper so email will only be sent when submit button is pressed
'If CStr(Request.Form("Submit")) <> "" Then
''Set MailObj = Server.CreateObject("JMail.SMTPMail")
''MailObj.ServerAddress=("localhost")
''MailObj.Sender = "info@xxxx.com"
''MailObj.AddRecipientCC "info@yyyy.co.uk"
''MailObj.Priority = 3
''MailObj.Subject = "Affiliate visit "
'MailObj.BodyFormat = 0 
'MailObj.MailFormat = 0 

Dim CDOMessage, CDOConfiguration
Set CDOConfiguration = CreateObject("CDO.Configuration")
With CDOConfiguration.Fields
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = SMTPUserName 'If you configured SMTP to send email using Username and Password
    .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SMTPPassword 'If you configured SMTP to send email using Username and Password
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'cdoBasic
	.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1 'cdoSendUsingPort
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

	.Update
End With


HTML = HTML & "<html>" 
HTML = HTML & "<head>" 
HTML = HTML & "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">"
HTML = HTML & "<title>Insurance affiliate visit:</title>" 
HTML = HTML & "<style> *,body,table,tr,td" 
HTML = HTML & "{font-family:verdana;font-size:10px;}"
HTML = HTML & "</style>"
HTML = HTML & "</head>" 
HTML = HTML & "<body>" 
HTML = HTML & "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"">"
HTML = HTML & "<tr valign=top>"
HTML = HTML & "<td>"
HTML = HTML & "</td>"
HTML = HTML & "</tr>"
HTML = HTML & "</table>"

HTML = HTML & "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"">"
HTML = HTML & "<tr>" 
HTML = HTML & "<td ><b>Affiliate visit</b>"&" Date "& FormatDateTime(Now(),0)&""&"</td>"
HTML = HTML & "<td>&nbsp;</td>"
HTML = HTML & "</tr>" 

HTML = HTML & "</table>"
HTML = HTML & "</body>" 
HTML = HTML & "</html>"


Set CDOMessage = CreateObject("CDO.Message")
	With CDOMessage

		Set .Configuration = CDOConfiguration

		.From = "john@net100.co.uk"
		.To = "info@net100.co.uk"
		.Subject = "Affiliate visit "
		.HtmlBody = HTML
        .Send
	End With
Set CDOMessage = Nothing
Set CDOConfiguration = Nothing

'MailObj.HTMLBody = HTML
'MailObj.Execute
'Set MailObj = Nothing

'End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd"> 
		

<html>
<head>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>


<link href="../Styles.css" rel="stylesheet" type="text/css">
</head>

<body text="#000099" link="#000066" vlink="#003366" alink="#00FF00" onLoad="MM_preloadImages('images/InsuranceButtons_r3_c1_f2.gif')">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  
  <tr>
    <td width="87%" valign="top">      <table width="100%"  border="0" cellspacing="0" cellpadding="1">
        
        <tr>
          <td valign="top">
            <table width="576" border="0" align="center" cellpadding="0" cellspacing="0">
              <!-- fwtable fwsrc="InsuranceButtons.png" fwbase="InsuranceButtons.gif" fwstyle="Dreamweaver" fwdocid = "1166313288" fwnested="0" -->
              <tr>
                <td><img src="images/spacer.gif" width="190" height="1" border="0" alt=""></td>
                <td><img src="images/spacer.gif" width="3" height="1" border="0" alt=""></td>
                <td><img src="images/spacer.gif" width="1" height="1" border="0" alt=""></td>
              </tr>
              <tr>
                <td><a href="http://www.noblemarine.co.uk/motorboatinsurance.php3?affid=606" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('InsuranceButtons_r1_c1','','images/InsuranceButtons_r1_c1_f2.gif',1);"><img src="images/InsuranceButtons_r1_c1.gif" alt="Moror Boat Insurance" name="submit" width="190" height="32" border="0" id="submit"></a></td>
                <td rowspan="3"><img name="InsuranceButtons_r1_c4" src="images/InsuranceButtons_r1_c4.gif" width="3" height="65" border="0" alt=""></td>
              </tr>
              <tr>
                <td><img name="InsuranceButtons_r2_c1" src="images/InsuranceButtons_r2_c1.gif" width="190" height="1" border="0" alt=""></td>
                <td><img src="images/spacer.gif" width="1" height="1" border="0" alt=""></td>
              </tr>
              <tr>
                <td><a href="http://www.noblemarine.co.uk/ribinsurance.php3?affid=606" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('InsuranceButtons_r3_c1','','images/InsuranceButtons_r3_c1_f2.gif',1);"><img name="InsuranceButtons_r3_c1" src="images/InsuranceButtons_r3_c1.gif" width="190" height="32" border="0" alt="RIB Insurance"></a></td>
                <td><img src="images/spacer.gif" width="1" height="32" border="0" alt=""></td>
              </tr>
            </table>            </td>
        </tr>
        <tr valign="top">
          <td><p class="txt12"><strong>What should I look out for?</strong></p>          </td>
        </tr>
        
    </table></td>
  </tr>
</table>
</body>
</html>
                            

Open in new window

Assuming page is submitted to itself, please see attached code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%

if Request.QueryString("affid") = 606 then
    ' wrapper so email will only be sent when submit button is pressed
    'If CStr(Request.Form("Submit")) <> "" Then
    ''Set MailObj = Server.CreateObject("JMail.SMTPMail")
    ''MailObj.ServerAddress=("localhost")
    ''MailObj.Sender = "info@xxxx.com"
    ''MailObj.AddRecipientCC "info@yyyy.co.uk"
    ''MailObj.Priority = 3
    ''MailObj.Subject = "Affiliate visit "
    'MailObj.BodyFormat = 0 
    'MailObj.MailFormat = 0 

    Dim CDOMessage, CDOConfiguration
    Set CDOConfiguration = CreateObject("CDO.Configuration")
    With CDOConfiguration.Fields
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = SMTPUserName 'If you configured SMTP to send email using Username and Password
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SMTPPassword 'If you configured SMTP to send email using Username and Password
	    .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'cdoBasic
	    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1 'cdoSendUsingPort
	    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

	    .Update
    End With


    HTML = HTML & "<html>" 
    HTML = HTML & "<head>" 
    HTML = HTML & "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">"
    HTML = HTML & "<title>Insurance affiliate visit:</title>" 
    HTML = HTML & "<style> *,body,table,tr,td" 
    HTML = HTML & "{font-family:verdana;font-size:10px;}"
    HTML = HTML & "</style>"
    HTML = HTML & "</head>" 
    HTML = HTML & "<body>" 
    HTML = HTML & "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"">"
    HTML = HTML & "<tr valign=top>"
    HTML = HTML & "<td>"
    HTML = HTML & "</td>"
    HTML = HTML & "</tr>"
    HTML = HTML & "</table>"

    HTML = HTML & "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"">"
    HTML = HTML & "<tr>" 
    HTML = HTML & "<td ><b>Affiliate visit</b>"&" Date "& FormatDateTime(Now(),0)&""&"</td>"
    HTML = HTML & "<td>&nbsp;</td>"
    HTML = HTML & "</tr>" 

    HTML = HTML & "</table>"
    HTML = HTML & "</body>" 
    HTML = HTML & "</html>"


    Set CDOMessage = CreateObject("CDO.Message")
	    With CDOMessage

		    Set .Configuration = CDOConfiguration

		    .From = "john@net100.co.uk"
		    .To = "info@net100.co.uk"
		    .Subject = "Affiliate visit "
		    .HtmlBody = HTML
            .Send
	    End With
    Set CDOMessage = Nothing
    Set CDOConfiguration = Nothing

    'MailObj.HTMLBody = HTML
    'MailObj.Execute
    'Set MailObj = Nothing

    'End If
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd"> 
		

<html>
<head>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>


<link href="../Styles.css" rel="stylesheet" type="text/css">
</head>

<body text="#000099" link="#000066" vlink="#003366" alink="#00FF00" onLoad="MM_preloadImages('images/InsuranceButtons_r3_c1_f2.gif')">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  
  <tr>
    <td width="87%" valign="top">      <table width="100%"  border="0" cellspacing="0" cellpadding="1">
        
        <tr>
          <td valign="top">
            <table width="576" border="0" align="center" cellpadding="0" cellspacing="0">
              <!-- fwtable fwsrc="InsuranceButtons.png" fwbase="InsuranceButtons.gif" fwstyle="Dreamweaver" fwdocid = "1166313288" fwnested="0" -->
              <tr>
                <td><img src="images/spacer.gif" width="190" height="1" border="0" alt=""></td>
                <td><img src="images/spacer.gif" width="3" height="1" border="0" alt=""></td>
                <td><img src="images/spacer.gif" width="1" height="1" border="0" alt=""></td>
              </tr>
              <tr>
                <td><a href="http://www.noblemarine.co.uk/motorboatinsurance.php3?affid=606" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('InsuranceButtons_r1_c1','','images/InsuranceButtons_r1_c1_f2.gif',1);"><img src="images/InsuranceButtons_r1_c1.gif" alt="Moror Boat Insurance" name="submit" width="190" height="32" border="0" id="submit"></a></td>
                <td rowspan="3"><img name="InsuranceButtons_r1_c4" src="images/InsuranceButtons_r1_c4.gif" width="3" height="65" border="0" alt=""></td>
              </tr>
              <tr>
                <td><img name="InsuranceButtons_r2_c1" src="images/InsuranceButtons_r2_c1.gif" width="190" height="1" border="0" alt=""></td>
                <td><img src="images/spacer.gif" width="1" height="1" border="0" alt=""></td>
              </tr>
              <tr>
                <td><a href="http://www.noblemarine.co.uk/ribinsurance.php3?affid=606" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('InsuranceButtons_r3_c1','','images/InsuranceButtons_r3_c1_f2.gif',1);"><img name="InsuranceButtons_r3_c1" src="images/InsuranceButtons_r3_c1.gif" width="190" height="32" border="0" alt="RIB Insurance"></a></td>
                <td><img src="images/spacer.gif" width="1" height="32" border="0" alt=""></td>
              </tr>
            </table>            </td>
        </tr>
        <tr valign="top">
          <td><p class="txt12"><strong>What should I look out for?</strong></p>          </td>
        </tr>
        
    </table></td>
  </tr>
</table>
</body>
</html>
                            
                                            

Open in new window

Thanks pateljitu
I was not sure about the meaning of your comment  the "page is submitted to itself" however the link now goes to the correct url but no email notification is received.
Does the code to send email exists on page motorboatinsurance.php3 OR ribinsurance.php3?affid=606
No these pages have no code related.

The present active page is at http://www.boatsforsalenow.com/Boat-Insurance/boat-insurance-info.asp this is using jmail
ASKER CERTIFIED SOLUTION
Avatar of pateljitu
pateljitu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Very many thanks pateljitu
That worked perfectly.

I will now study you method in order to learn.
Regards

John