CDO mail and Frontpage Database (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


gizmolady -> CDO mail and Frontpage Database (2/22/2007 12:21:42)

Sending Mail with CDO

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

Hi any help would be appreciated...
I have a frontpage form.asp it saves to a database.. that works good
but now I need to email the results from the items they picked,
I have CDO working when they click the submit button and it does
email me .. with nothing on it..
I need the body of the email.. to have the following info on..
I can't figure it out.. The username is a response.write session.. that I have saved on the form.. the hidden field is another field I need displayed on the email.. But the FP_saved field is from the database..

<input type="hidden" name="UserName" value="<%Response.Write Session("Username")%>">
<input type="hidden" name="ceramamicmug" value="CeramicMug">
and the Session("FP_SavedFields")=arFormFields0
Session("FP_SavedValues")=arFormValues0

Thanks you.. VERY much




Spooky -> RE: CDO mail and Frontpage Database (2/22/2007 13:47:55)

What does the CDO code look like?




gizmolady -> RE: CDO mail and Frontpage Database (2/22/2007 14:57:16)

Dim sMsg
Dim sTo
Dim sFrom
Dim sSubject
Dim sTextBody

sTo = "FSHAYWARD@EARTHLINK.NET"
sFrom = "fSHAYWARD@EARTHLINK.NET"
sSubject = "Web Page Order"
Spooky
This is my CDO..
I just need the username and the fp saved field inserted into the Textbody, I believe
it sounds easy... but it has driven me in circles..
Dim objMail
'Create the mail object
Set objMail = Server.CreateObject("CDO.Message")

'Set key properties
objMail.From = sFrom
objMail.To = sTo
objMail.Subject= sSubject
objMail.TextBody = "has ordered CeramicMugs"
strBody = strBody

'Send the email
objMail.Send

'Clean-up mail object
Set objMail = Nothing
%>




Spooky -> RE: CDO mail and Frontpage Database (2/22/2007 16:01:21)

An example would be :

strBody = Session("FP_SavedValues")

'Set key properties
objMail.From = sFrom
objMail.To = sTo
objMail.Subject= sSubject
objMail.TextBody = strBody


You would need to test to see what the session contains or use a variation of that code for strBody




gizmolady -> RE: CDO mail and Frontpage Database (2/22/2007 22:02:44)

I'm stumped... can you give me direction on how to
use a RESPONSE.WRITE session(username)
in a CDoMail? I've tried saving as a variable.. that didn't work either..

UserName" value="<%Response.Write Session("Username")%>">
hidden" name="ceramamicmug" value="CeramicMug">

My CDo


Dim sMsg
Dim sTo
Dim sFrom
Dim sSubject
Dim sTextBody

sTo = " "
sFrom = ""
sSubject = "Web Page Order"

Dim objMail
'Create the mail object
Set objMail = Server.CreateObject("CDO.Message")


'Set key properties
objMail.From = sFrom
objMail.To = sTo
objMail.Subject= sSubject
objMail.TextBody = "has ordered"
strBody = Session("FP_SavedValues")
Session("FP_SavedFields")=arFormFields0


'Send the email
objMail.Send

'Clean-up mail object
Set objMail = Nothing
%>




ou812 -> RE: CDO mail and Frontpage Database (2/23/2007 0:21:02)

Here's where Spooky is showing to load the values in.
strBody = Session("FP_SavedValues")

But, I think you wanted to load the values and some other things (I'm not sure what is what, but this should give you an idea). So you could do something like this:
' Load the first item in the variable, then append other data as needed
strBody = "Username: " & Session(Username) & vbcrlf
strBody = strBody & "Item: & request.form(ceramamicmug) & vbcrlf
strBody = strBody & "Has ordered:" & vbcrlf
strBody = strBody & Session(FP_SavedValues)

then just set your objMail.TextBody like this:
objMail.TextBody = strBody





gizmolady -> RE: CDO mail and Frontpage Database (2/23/2007 9:49:53)

I'm SO SO close... but not there...

strBody = "Username: "& Session("Username") & vbcrlf
The above works to pass along the username in an email.. But as soon as I add

strBody = strBody & Session(FP_SavedValues)
it quits working

What am I doing wrong now? Its the last piece of this puzzle.. I just
need one field from the saved database... Am I not putting in the proper
place?

Thank you... Thank you...





gizmolady -> RE: CDO mail and Frontpage Database (2/24/2007 1:05:10)


Can anyone see a reason why this FP_savedValues doesn't work?

<%
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.To = "somewhere.com"
objCDOMail.From = "somewhere.com"
objCDOMail.Subject = "Ceramic Mugs"
strBody = "Username:" & Session("Username") & vbCRLF
strBody = strbody & "CeramicMugs: "& Session(fp_) & vbCRLF


strBody= strbody & Session("FP_SavedValues")


objCDOMail.Body = strBody
objCDOMail.BodyFormat = 1
objCDOMail.MailFormat = 1
objCDOMail.Send
Set objCDOMail = Nothing
%>

It is the LAST peice of the puzzle..




Spooky -> RE: CDO mail and Frontpage Database (2/24/2007 3:16:58)

What does this give you?

objCDOMail.Body = arFormFields0




gizmolady -> RE: CDO mail and Frontpage Database (2/24/2007 9:09:44)



I tried this
objCDOMail.Body = arFormFields0
but that gives me nothing. I think that overwrites this..

strBody = "Username:" & Session("Username") & vbCRLF
strBody = strbody & "CeramicMugs: "& Session(fp_) & vbCRLF
strBody= strbody & Session("FP_SavedValues")
objCDOMail.Body = strBody


any ideas?
i'm running out of them..
thanks




gizmolady -> RE: CDO mail and Frontpage Database (2/24/2007 9:26:56)


I think this is where i need to save do i use a session?

fp_sQry="SELECT * FROM cmugs WHERE (cmugs = '::cmugs::')"




Spooky -> RE: CDO mail and Frontpage Database (2/24/2007 9:30:31)

What is the complete code from the head of that page?




gizmolady -> RE: CDO mail and Frontpage Database (2/24/2007 9:35:50)

Hope I"m sending this right...


<%
' FP_ASP ASP Automatically generated by a Frontpage Component. Do not Edit.

On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Session.LCID = 1033
Err.Clear

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
Err.Clear

Set fp_conn = Server.CreateObject("ADODB.Connection")
FP_DumpError strErrorUrl, "Cannot create connection"

Set fp_rs = Server.CreateObject("ADODB.Recordset")
FP_DumpError strErrorUrl, "Cannot create record set"

fp_conn.Open Application("resultceramic_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"

fp_rs.Open "Results", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
FP_DumpError strErrorUrl, "Cannot open record set"

fp_rs.AddNew
FP_DumpError strErrorUrl, "Cannot add new record set to the database"
Dim arFormFields0(3)
Dim arFormDBFields0(3)
Dim arFormValues0(3)

arFormFields0(0) = "cmugs"
arFormDBFields0(0) = "cmugs"
arFormValues0(0) = Request("cmugs")
arFormFields0(1) = "UserName"
arFormDBFields0(1) = "UserName"
arFormValues0(1) = Request("UserName")
arFormFields0(2) = "CeramicMugs"
arFormDBFields0(2) = "CeramicMugs"
arFormValues0(2) = Request("CeramicMugs")

FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0

FP_SaveFieldToDB fp_rs, Now, "Timestamp"

fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"

fp_rs.Close
fp_conn.Close

Session("FP_SavedFields")=arFormFields0
Session("FP_SavedValues")=arFormValues0
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")

End If
End If

Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")

%>
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Thank you for your order</title>
</head>

<body>

<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveDatabase" startspan SuggestedExt="asp" S-DataConnection="resultceramic" S-RecordSource="Results" U-Database-URL="fpdb/resultceramic.mdb" S-Builtin-Fields="Timestamp" S-Builtin-DBFields="Timestamp" S-Form-Fields="cmugs UserName CeramicMugs" S-Form-DBFields="cmugs UserName CeramicMugs" U-ASP-Include-Url="_fpclass/fpdbform.inc" U-Confirmation-Url="orderform.htm" --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="_fpclass/fpdbform.inc"--><!--webbot bot="SaveDatabase" endspan i-checksum="40548" -->
<p align="center"> </p>
<p align="center">Thank you for your order.</p>
<p align="center">You have selected  <nobr>
<!--webbot bot="DatabaseRegionStart" s-columnnames="cmugs,id" s-columntypes="202,202" s-dataconnection="storeg" b-tableformat="FALSE" b-menuformat="TRUE" s-menuchoice="cmugs" s-menuvalue="cmugs" b-tableborder="TRUE" b-tableexpand="TRUE" b-tableheader="TRUE" b-listlabels="TRUE" b-listseparator="TRUE" i-listformat="0" b-makeform="FALSE" s-recordsource="cmugs" s-displaycolumns="cmugs" s-criteria="[cmugs] EQ {cmugs} +" s-order s-sql="SELECT * FROM cmugs WHERE (cmugs = '::cmugs::')" b-procedure="FALSE" clientside suggestedext="asp" s-defaultfields="cmugs=" s-norecordsfound="No records returned." i-maxrecords="256" i-groupsize="0" botid="0" u-dblib="_fpclass/fpdblib.inc" u-dbrgn1="_fpclass/fpdbrgn1.inc" u-dbrgn2="_fpclass/fpdbrgn2.inc" preview=" <span style="color: rgb(0,0,0); background-color: rgb(255,255,0)">Database</span> " b-InForm="TRUE" b-UseDotNET="FALSE" CurrentExt sa-InputTypes="202" b-DataGridFormat="FALSE" b-DGridAlternate="TRUE" sa-CritTypes="202" b-WasTableFormat="FALSE" startspan --><!--#include file="_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM cmugs WHERE (cmugs = '::cmugs::')"
fp_sDefault="cmugs="
fp_sNoRecords="No records returned."
fp_sDataConn="storeg"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="cmugs"
fp_sMenuValue="cmugs"
fp_sColTypes="&cmugs=202&id=202&"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--webbot bot="DatabaseRegionStart" endspan i-checksum="27263" --><select NAME="cmugs" SIZE="1">
<!--webbot bot="AspInclude" clientside u-incfile="_fpclass/fpdbrgn1.inc" startspan --><!--#include file="_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="AspInclude" endspan i-checksum="63746" -->
<option><%=FP_FieldHTML(fp_rs,"cmugs")%></option>
<!--webbot bot="AspInclude" clientside u-incfile="_fpclass/fpdbrgn2.inc" startspan --><!--#include file="_fpclass/fpdbrgn2.inc"-->
<!--webbot bot="AspInclude" endspan i-checksum="63754" --></select><!--webbot bot="DatabaseRegionEnd" b-tableformat="FALSE" b-menuformat="TRUE" u-dbrgn2="_fpclass/fpdbrgn2.inc" i-groupsize="0" clientside preview=" <span style="color: rgb(0,0,0); background-color: rgb(255,255,0)">Results</span> " startspan --><!--webbot bot="DatabaseRegionEnd" endspan --></nobr> 
Ceramic Mugs  <input type="submit" value="Place Order" name="B1"> 
</p>
<p align="center">Click on the BACK button on your browser to change your order.</p>
<p align="center"><a href="orderform.htm">Return to order page</a></p>
<p> </p>
<p> </p>
<p> </p>
<input type="hidden" name="UserName" value="<%Response.Write Session("Username")%>">
<input type="hidden" name="CeramicMugs" value="CeramicMugs">
</form>
</html>
<%
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.To = "fshayward@earthlink.net"
objCDOMail.From = "fshAYWARD@EARTHLINK.NET"
objCDOMail.Subject = "Ceramic Mugs"
strBody = "Username:" & Session("Username") & vbCRLF
strBody = strbody & "CeramicMugs: "& Session(fp_) & vbCRLF
strBody= strbody & Session("FP_SavedValues")

objCDOMail.Body =strbody
objCDOMail.BodyFormat = 1
objCDOMail.MailFormat = 1
objCDOMail.Send
Set objCDOMail = Nothing
%>
</body>

</html>




gizmolady -> RE: CDO mail and Frontpage Database (2/24/2007 9:40:15)

This first page they choose what they want to order
The second page.. which is the code I sent.. they say Yes I want to order this and it is sent to a dbase and
I need that order email out and also saved to the database.




Spooky -> RE: CDO mail and Frontpage Database (2/24/2007 9:42:02)

Ahh - ok, your email code should be inserted as below :

Session.LCID = Session("FP_OldLCID")

Email code here

End If
End If 


The code isnt processed until the submit button is pressed, so the values will more than likely be blank where the code is presently




gizmolady -> RE: CDO mail and Frontpage Database (2/24/2007 9:57:25)

Oh dear.. I moved the code and now it doesn't send the email





gizmolady -> RE: CDO mail and Frontpage Database (2/24/2007 10:01:39)

Maybe I did it wrong heres what it looks like now
<%
' FP_ASP ASP Automatically generated by a Frontpage Component. Do not Edit.

On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Session.LCID = 1033
Err.Clear

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
Err.Clear

Set fp_conn = Server.CreateObject("ADODB.Connection")
FP_DumpError strErrorUrl, "Cannot create connection"

Set fp_rs = Server.CreateObject("ADODB.Recordset")
FP_DumpError strErrorUrl, "Cannot create record set"

fp_conn.Open Application("resultceramic_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"

fp_rs.Open "Results", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
FP_DumpError strErrorUrl, "Cannot open record set"

fp_rs.AddNew
FP_DumpError strErrorUrl, "Cannot add new record set to the database"
Dim arFormFields0(3)
Dim arFormDBFields0(3)
Dim arFormValues0(3)

arFormFields0(0) = "cmugs"
arFormDBFields0(0) = "cmugs"
arFormValues0(0) = Request("cmugs")
arFormFields0(1) = "UserName"
arFormDBFields0(1) = "UserName"
arFormValues0(1) = Request("UserName")
arFormFields0(2) = "CeramicMugs"
arFormDBFields0(2) = "CeramicMugs"
arFormValues0(2) = Request("CeramicMugs")

FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0

FP_SaveFieldToDB fp_rs, Now, "Timestamp"

fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"

fp_rs.Close
fp_conn.Close

Session("FP_SavedFields")=arFormFields0
Session("FP_SavedValues")=arFormValues0
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
Response.Redirect "orderform.htm"


Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
<%
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.To = "fshayward@earthlink.net"
objCDOMail.From = "fshAYWARD@EARTHLINK.NET"
objCDOMail.Subject = "Ceramic Mugs"
strBody = "Username:" & Session("Username") & vbCRLF
strBody = strbody & "CeramicMugs: "& Session(fp_) & vbCRLF
strBody= strbody & Session("FP_SavedValues")

objCDOMail.Body =strbody
objCDOMail.BodyFormat = 1
objCDOMail.MailFormat = 1
objCDOMail.Send
Set objCDOMail = Nothing

end if
end if
%>

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Thank you for your order</title>
</head>

<body>

<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveDatabase" startspan SuggestedExt="asp" S-DataConnection="resultceramic" S-RecordSource="Results" U-Database-URL="fpdb/resultceramic.mdb" S-Builtin-Fields="Timestamp" S-Builtin-DBFields="Timestamp" S-Form-Fields="cmugs UserName CeramicMugs" S-Form-DBFields="cmugs UserName CeramicMugs" U-ASP-Include-Url="_fpclass/fpdbform.inc" U-Confirmation-Url="orderform.htm" --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="_fpclass/fpdbform.inc"--><!--webbot bot="SaveDatabase" endspan i-checksum="40548" -->
<p align="center"> </p>
<p align="center">Thank you for your order.</p>
<p align="center">You have selected <nobr>
<!--webbot bot="DatabaseRegionStart" s-columnnames="cmugs,id" s-columntypes="202,202" s-dataconnection="storeg" b-tableformat="FALSE" b-menuformat="TRUE" s-menuchoice="cmugs" s-menuvalue="cmugs" b-tableborder="TRUE" b-tableexpand="TRUE" b-tableheader="TRUE" b-listlabels="TRUE" b-listseparator="TRUE" i-listformat="0" b-makeform="FALSE" s-recordsource="cmugs" s-displaycolumns="cmugs" s-criteria="[cmugs] EQ {cmugs} +" s-order s-sql="SELECT * FROM cmugs WHERE (cmugs = '::cmugs::')" b-procedure="FALSE" clientside suggestedext="asp" s-defaultfields="cmugs=" s-norecordsfound="No records returned." i-maxrecords="256" i-groupsize="0" botid="0" u-dblib="_fpclass/fpdblib.inc" u-dbrgn1="_fpclass/fpdbrgn1.inc" u-dbrgn2="_fpclass/fpdbrgn2.inc" preview=" <span style="color: rgb(0,0,0); background-color: rgb(255,255,0)">Database</span> " b-InForm="TRUE" b-UseDotNET="FALSE" CurrentExt sa-InputTypes="202" b-DataGridFormat="FALSE" b-DGridAlternate="TRUE" sa-CritTypes="202" b-WasTableFormat="FALSE" startspan --><!--#include file="_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM cmugs WHERE (cmugs = '::cmugs::')"
fp_sDefault="cmugs="
fp_sNoRecords="No records returned."
fp_sDataConn="storeg"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="cmugs"
fp_sMenuValue="cmugs"
fp_sColTypes="&cmugs=202&id=202&"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--webbot bot="DatabaseRegionStart" endspan i-checksum="27263" --><select NAME="cmugs" SIZE="1">
<!--webbot bot="AspInclude" clientside u-incfile="_fpclass/fpdbrgn1.inc" startspan --><!--#include file="_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="AspInclude" endspan i-checksum="63746" -->
<option><%=FP_FieldHTML(fp_rs,"cmugs")%></option>
<!--webbot bot="AspInclude" clientside u-incfile="_fpclass/fpdbrgn2.inc" startspan --><!--#include file="_fpclass/fpdbrgn2.inc"-->
<!--webbot bot="AspInclude" endspan i-checksum="63754" --></select><!--webbot bot="DatabaseRegionEnd" b-tableformat="FALSE" b-menuformat="TRUE" u-dbrgn2="_fpclass/fpdbrgn2.inc" i-groupsize="0" clientside preview=" <span style="color: rgb(0,0,0); background-color: rgb(255,255,0)">Results</span> " startspan --><!--webbot bot="DatabaseRegionEnd" endspan --></nobr>
Ceramic Mugs <input type="submit" value="Place Order" name="B1">
</p>
<p align="center">Click on the BACK button on your browser to change your order.</p>
<p align="center"><a href="orderform.htm">Return to order page</a></p>
<p> </p>
<p> </p>
<p> </p>
<input type="hidden" name="UserName" value="<%Response.Write Session("Username")%>">
<input type="hidden" name="CeramicMugs" value="CeramicMugs">
</form>
</html>

</body>

</html>






Spooky -> RE: CDO mail and Frontpage Database (2/24/2007 10:03:05)

Like so?
Remember it will only mail when you post the page

Session.LCID = Session("FP_OldLCID")

Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.To = "fshayward@earthlink.net"
objCDOMail.From = "fshAYWARD@EARTHLINK.NET"
objCDOMail.Subject = "Ceramic Mugs"
strBody = "Username:" & Session("Username") & vbCRLF
objCDOMail.Body =strbody
objCDOMail.BodyFormat = 1
objCDOMail.MailFormat = 1
objCDOMail.Send
Set objCDOMail = Nothing

End If
End If 




gizmolady -> RE: CDO mail and Frontpage Database (2/24/2007 10:21:53)

HI..
This is what the page looks like..
Thank you for your order.
You have selected (DROPDOWN MENU) Ceramic Mugs
Click on the BACK button on your browser to change your order.

When they click on the dropdown choice and click on SUBMit, isn't
that posting? (I'm most likely wrong)

I need the item they selected email.

any help would be appreciated thanks





Spooky -> RE: CDO mail and Frontpage Database (2/25/2007 5:05:53)

quote:

When they click on the dropdown choice and click on SUBMit, isn't
that posting? (I'm most likely wrong)


Yes it is - does nothing occur when they submit?
Normally after posting the page it gets redirected to a thankyou page. Yours doesnt seem to do that




gizmolady -> RE: CDO mail and Frontpage Database (2/25/2007 12:42:39)

I've added a thankyou page when they press submit

But still no luck... maybe I'am going about this the wrong way?


fp_sQry="SELECT * FROM cmugs WHERE (cmugs = '::cmugs::')"
How can I save the result from this qry to a session or variable so
I can email the result.

Thank you.. I'm a newbie and I have learned so much.. and know so little...




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.109375