Click here to Skip to main content
15,914,417 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: update tables row with vbscript in asp Pin
Guffa12-Nov-07 1:57
Guffa12-Nov-07 1:57 
GeneralRe: update tables row with vbscript in asp Pin
idsanjeevjha12-Nov-07 15:55
idsanjeevjha12-Nov-07 15:55 
AnswerRe: update tables row with vbscript in asp Pin
Guffa12-Nov-07 22:11
Guffa12-Nov-07 22:11 
QuestionRe: update tables row with vbscript in asp [modified] Pin
idsanjeevjha12-Nov-07 22:56
idsanjeevjha12-Nov-07 22:56 
AnswerRe: update tables row with vbscript in asp Pin
Guffa13-Nov-07 12:46
Guffa13-Nov-07 12:46 
GeneralRe: update tables row with vbscript in asp Pin
idsanjeevjha13-Nov-07 16:56
idsanjeevjha13-Nov-07 16:56 
AnswerRe: update tables row with vbscript in asp Pin
Guffa14-Nov-07 3:05
Guffa14-Nov-07 3:05 
QuestionASP Email Script Not Working Pin
MelDrop9-Nov-07 5:06
MelDrop9-Nov-07 5:06 
I have added the script below to my website and if it is in test mode, it works fine - it writes the data to the screen. But when I take it out of test mode, it doesn't email me the data. I have pasted the script along with my code for the form. Can someone please tell me why it's not emailing? (Also, fyi, I do have a .txt file setup for the formatting of the email.) Thank you!

ASP Script named sendmail_cdo.asp

<%
option explicit

'---------------------------------------------------------------------------------------------------
'FORM MAIL SCRIPT
'----------------
'usage:
'<form ACTION="sendmail.asp" ...>
'
'hidden fields:
' redirect - the url to redirect to when the mail has been sent (REQUIRED)
' mailto - the email address of the recipient (separate multiple recipients with commas) (REQUIRED)
' cc - the email address of the cc recipient (separate multiple recipients with commas) (OPTIONAL)
' bcc - the email address of the bcc recipient (separate multiple recipients with commas) (OPTIONAL)
' mailfrom - the email address of the sender (REQUIRED)
' subject - the subject line of the email (REQUIRED)
' message - the message to include in the email above the field values. not used when a template is being used. (OPTIONAL)
' template - specifies a text or html file to use as the email template, relative to the location of the sendmail script. (e.g. ../email.txt)
' A template should reference form fields like this: [$Field Name$]
' html - if this has the value "yes", the email will be sent as an html email. only used if a template is supplied.
' testmode - if this is set to "yes", the email contents will be written to the screen instead of being emailed.
'---------------------------------------------------------------------------------------------------
dim pde : set pde = createobject("scripting.dictionary")
'---------------------------------------------------------------------------------------------------
'PREDEFINED ADDRESSES for the "mailto" hidden field
'if you don't want to reveal email addresses in hidden fields, use a token word instead and specify
'below which email address it applies to. e.g. <input type="hidden" name="mailto" value="%stratdepartment%">
'ALSO, in the same way, you can use %mailfrom% to hide the originating email address
pde.add "%contactform%", "myemail@someaddress.com"
pde.add "%salesenquiry%", "anotheremail@someaddress.com"
'---------------------------------------------------------------------------------------------------

function getTextFromFile(path)
dim fso, f, txt
set fso = createobject("Scripting.FileSystemObject")
if not fso.fileexists(path) then
getTextFromFile = ""
exit function
end if
set f = fso.opentextfile(path,1)
if f.atendofstream then txt = "" else txt = f.readall
f.close
set f = nothing
set fso = nothing
getTextFromFile = txt
end function

dim redir, mailto, mailfrom, subject, item, body, cc, bcc, message, html, template, usetemplate, testmode
redir = request.form("redirect")
mailto = request.form("mailto")
if pde.exists(mailto) then mailto = pde(mailto)
cc = request.form("cc")
bcc = request.form("bcc")
mailfrom = request.form("mailfrom")
if mailfrom = "" then mailfrom = pde("%mailfrom%")
subject = request.form("subject")
message = request.form("message")
template = request.form("template")
testmode = lcase(request.form("testmode"))="yes"

if len(template) > 0 then template = getTextFromFile(server.mappath(template))
if len(template) > 0 then usetemplate = true else usetemplate = false
dim msg : set msg = server.createobject("CDO.Message")
msg.subject = subject
msg.to = mailto
msg.from = mailfrom
if len(cc) > 0 then msg.cc = cc
if len(bcc) > 0 then msg.bcc = bcc

if not usetemplate then
body = body & message & vbcrlf & vbcrlf
else
body = template
end if
for each item in request.form
select case item
case "redirect", "mailto", "cc", "bcc", "subject", "message", "template", "html", "testmode"
case else
if not usetemplate then
if item <> "mailfrom" then body = body & item & ": " & request.form(item) & vbcrlf & vbcrlf
else
body = replace(body, "[$" & item & "$]", replace(request.form(item),vbcrlf,"<br>"))
end if
end select
next

if usetemplate then 'remove any leftover placeholders
dim rx : set rx = new regexp
rx.pattern = "\[\$.*\$\]"
rx.global = true
body = rx.replace(body, "")
end if

if usetemplate and lcase(request.form("html")) = "yes" then
msg.htmlbody = body
else
msg.textbody = body
end if
if testmode then
if lcase(request.form("html")) = "yes" then
response.write "<pre>" & vbcrlf
response.write "Mail to:" & mailto & vbcrlf
response.write "Mail from:" & mailfrom & vbcrlf
if len(cc) > 0 then response.write "Cc:" & cc & vbcrlf
if len(bcc) > 0 then response.write "Bcc:" & bcc & vbcrlf
response.write "Subject:" & subject & vbcrlf & string(80,"-") & "</pre>"
response.write body
else
response.write "<html><head><title>Sendmail.asp Test Mode</title></head><body><pre>" & vbcrlf
response.write "Mail to: " & mailto & vbcrlf
response.write "Mail from: " & mailfrom & vbcrlf
if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
response.write "Subject: " & subject & vbcrlf & vbcrlf
response.write string(80,"-") & vbcrlf & vbcrlf & "<span style=""color:blue;"">"
response.write body & "</span>" & vbcrlf & vbcrlf
response.write string(80,"-") & vbcrlf & "**END OF EMAIL**</pre></body></html>"
end if
else
msg.send
response.redirect redir
end if
set msg = nothing
%>







Form page...
<form name="form1" method="post" action="sendmail_cdo.asp">
<div align="left">
<p class="style3">
<input name="redirect" type="hidden" id="redirect" value="surveycomplete.htm">
<input name="mailto" type="hidden" id="mailto" value="melissawaldrop@comcast.net" />
<input name="subject" type="hidden" id="subject" value="New Inquiry">
<input name="template" type="hidden" id="template" value="contactform.txt">
<input name="testmode" type="hidden" id="testmode" value="no">
</p>
<p class="style3">First Name
<input name="FName" type="text" id="FName">
Last Name
<input name="LName" type="text" id="LName">
</p>
<p class="style20"><span class="style3"><span class="style31">Email</span>
<input name="Email" type="text" id="Email">
<span class="style31">Phone </span>
<input name="Phone" type="text" id="Phone">
</span> </p>
<p>
<input type="submit" name="Submit" value="Send">
</p>
</div>
</form>

Questionhow to break a table into two tables with javascript? Pin
andylaw8-Nov-07 22:47
andylaw8-Nov-07 22:47 
AnswerRe: how to break a table into two tables with javascript? Pin
Guffa9-Nov-07 12:38
Guffa9-Nov-07 12:38 
GeneralRe: how to break a table into two tables with javascript? Pin
andylaw9-Nov-07 15:41
andylaw9-Nov-07 15:41 
GeneralRe: how to break a table into two tables with javascript? Pin
Michael Sync10-Nov-07 23:10
Michael Sync10-Nov-07 23:10 
Questionproblem with registration of new website on IIS Pin
0x49D18-Nov-07 20:01
0x49D18-Nov-07 20:01 
AnswerRe: problem with registration of new website on IIS Pin
Michael Sync8-Nov-07 20:30
Michael Sync8-Nov-07 20:30 
GeneralRe: problem with registration of new website on IIS Pin
0x49D18-Nov-07 20:41
0x49D18-Nov-07 20:41 
AnswerRe: problem with registration of new website on IIS Pin
Vasudevan Deepak Kumar8-Nov-07 21:03
Vasudevan Deepak Kumar8-Nov-07 21:03 
GeneralRe: problem with registration of new website on IIS Pin
0x49D18-Nov-07 21:10
0x49D18-Nov-07 21:10 
QuestionContent Aware Image Resizing?? Pin
e36k2248-Nov-07 14:46
e36k2248-Nov-07 14:46 
AnswerRe: Content Aware Image Resizing?? Pin
Mark Churchill8-Nov-07 17:05
Mark Churchill8-Nov-07 17:05 
GeneralRe: Content Aware Image Resizing?? Pin
e36k2248-Nov-07 20:01
e36k2248-Nov-07 20:01 
GeneralRe: Content Aware Image Resizing?? Pin
Mark Churchill8-Nov-07 20:21
Mark Churchill8-Nov-07 20:21 
QuestionSearch Engines Pin
Brendan Vogt8-Nov-07 9:18
Brendan Vogt8-Nov-07 9:18 
AnswerRe: Search Engines Pin
Michael Sync8-Nov-07 18:31
Michael Sync8-Nov-07 18:31 
AnswerRe: Search Engines Pin
AliAmjad9-Nov-07 0:16
AliAmjad9-Nov-07 0:16 
GeneralRe: Search Engines Pin
Manuel F. Hernandez9-Nov-07 6:51
Manuel F. Hernandez9-Nov-07 6:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.