Is Exchange/Outlook required to be on the same box as web server to function properly.
If not, are there any dangers in using CDO in directing a web form contents to an email address (mine of course)?
I'm not an expert programmer, but am somewhat familiar with .asp and .net. I'll let you know if you go over my head. Any help would be greatly appreciated.
8 11831
hi there,
not really.. all you need is a an smtp server to manage outgoing mail messages.. it doesn't have to be on the same box.. dangers? well.. not that i know of as long as you are behind a properly configured firewall or an antivirus.. take care.
Thanks Sashi for the quick reply. I can't seem to get the code right to use a remote smtp server. Any suggestions? I have tried the following code with no success...what do you think?
Start David's Test Code---- - <%
-
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 "%DirectMailRequest%", "thermocraft@satx.rr.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"))="no"
-
-
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
-
%>
-
End David's Test Code---
hi there,
you need to use the configuaration object for ur settings of smtp server and the port.
something like ths -
-
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
-
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1"
-
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
-
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
-
objCDOSYSCon.Fields.Update
Does smtpserver have to be an ip address? Can I use "smtp-server.satx.rr.com"?
Also, does it matter where I Set the objCDOSYSCon?
The code I'm using is accepting the info from my form, then redirecting to a thank you page. But it is still not sending the information to my email address.
I place the objCDOSYSCon near ("CDO.message"). - <%
-
option explicit
-
-
'Dim objCDOSYSCon
-
'Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
-
'objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp-server.satx.rr.com"
-
'objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
-
'objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
-
'objCDOSYSCon.Fields.Update
-
-
'---------------------------------------------------------------------------------------------------
-
'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%", "davidd@thermo-craft.com"
-
pde.add "%salesenquiry%", "dave.dura@gmail.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"))="no"
-
-
if len(template) > 0 then template = getTextFromFile(server.mappath(template))
-
if len(template) > 0 then usetemplate = true else usetemplate = false
-
Dim objCDOSYSCon
-
set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
-
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp-server.satx.rr.com"
-
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
-
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
-
objCDOSYSCon.Fields.Update
-
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
-
%>
-
Hi Duran,
the practical way is to leave the ip of your SMTP server to it's localhost address, which is 127.0.0.1.. this is if you have your SMTP server.. you can also specify an external ip address or hostname if you have no SMTP in server your network.. take care my fren..
Sashi and tejaswini
I got everything to work!!! Thanks for your help. This is the first time I use a forum to ask for help, I'm glad I did. Mission Accomplished!!!
David Duran
Hi Dave,
at last ah? :) good luck and take care my fren.. :)
Reminder to members posting to this thread: Please use code tags when posting code.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John |
last post by:
Could anyone please help me on this??
I have a php script page, which is basically quiz. Visitors (after login in
with their email address) are supposed to answer each question, and when
they...
|
by: Paul Cheevers |
last post by:
Hi,
This is driving me nuts to say the least!!!!!
I am trying to send an email from some server side ASP code and the CC field
is giving me some problems.
The code works fine if I have one...
|
by: Bhavna |
last post by:
Hello
Does anyone know what this message could be regarding?
The application seems to fall over on the following line.
Dim variable1 As SqlString = Arraylist1(i
The first time the code runs...
|
by: me |
last post by:
I have a Class Library that contains a Form and several helper classes. A
thread gets created that performs processing of data behind the scenes and
the Form never gets displayed (it is for debug...
|
by: rbazinet |
last post by:
I have a VS 2003 C# project, web app with a bunch of DLL's. When I compile
my project I often times get this message:
Unexpected error creating debug information file 'C:\DevProjects\Allstar...
|
by: Liz Patton |
last post by:
Here's the exception:
System.Exception: Unable to send mail: Could not access 'CDO.Message'
object. ---> System.Web.HttpException: Could not access 'CDO.Message'
object. --->...
|
by: Neil Stevens |
last post by:
Hi,
I would like to implements a message queue much like i used to in vb6 as
below:-
dim myMsg as MSG
while (PeekMessage(myMsg, hWnd, 0, 0))
if myMsg.Msg = WM_QUIT Then
End
end if
|
by: shots86 |
last post by:
I am having problems sending emails via the CDO.Message object from an
ASP script which was working fine. On the server I can still send
emails via the CDO.Message from a .vbs script executed on...
|
by: desktop |
last post by:
I have read in Bjarne Stroustrup that using malloc and free should be
avoided in C++ because they deal with uninitialized memory and one
should instead use new and delete.
But why is that a...
|
by: Ben |
last post by:
Environment Info:
- MS Access Sales System (front-end)
- SQL Server Standard (back-end)
Information of the Problem:
** In the Inventory items data:
- when user enters a new item and does...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |