[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

form mail

I need form mail that will work with the Register.com server.  Can anyone help?

0
brycol24
Asked:
brycol24
  • 6
  • 3
  • 2
  • +1
1 Solution
 
aprestoCommented:
couldnt you not use CDO?

<%
Dim sFrom, sTo, sCC, sBCC, sSubject, sBody

sFrom = "you@hotmail.com"
sTo = "me@hotmail.com"
sCC = ""
sBCC = ""
sSubject = "Here's the test email!"
sBody = "Hello!" & vbCrLf & vbCrLf & _
              "I hope you're having a great day!" & vbCrLf & vbCrLf & _
              "Bye!"
Call SendEmail(sFrom, sTo, sCC, sBCC, sSubject, sBody)

Function SendEmail(sFrom, sTo, sCC, sBCC, sSubject, sBody)
  Dim MyMail
  Set MyMail = Server.CreateObject("CDONTS.NewMail")
  MyMail.From = sFrom
  MyMail.To = sTo
  MyMail.Cc = sCC
  MyMail.Bcc = sBCC
  MyMail.Subject = sSubject
  MyMail.Body = sBody
  MyMail.Send
  Set MyMail = Nothing
end function
%>
0
 
aprestoCommented:
thats CDONTS for NT systems, for cdo change this:

 Set MyMail = Server.CreateObject("CDONTS.NewMail")

to this:

Set myMail=CreateObject("CDO.Message")
0
 
aprestoCommented:
then just use a form and ASP to get the values you want in there, is this what your after?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
brycol24Author Commented:
APRESTO,

To be honest I'm not sure what I'm after.  I just need form mail script that can be used on a web page so when someone fills out that mail form it will be sent to my e-mail...Is that the code you gave me?
0
 
aprestoCommented:
yeh it is, you just create an HTML form with fields you need and then put the code above in an ASP page and request.form the values from the form and store them in variables and refer to the variables in the code above, for example for the email:

dim FROMemail
FROMemail = request.form("Useremail")

...

MyMail.From = FROMemail
myMail.To = "your@email.com"
0
 
brycol24Author Commented:
apresto,

I can't save the page as an HTM page but it has to be ASP?

0
 
aprestoCommented:
yeh, its has to be an asp page to be able to send mail.

http://www.w3schools.com/asp/asp_send_email.asp
0
 
aprestoCommented:
Have your form look like this(emailform.htm):

<html>
<head>
<title>Email form</title>
</head>
<body>

<form method="post" action="sendmail.asp">
<table>
<tr>
      <td>Your Name:</td>
      <td><input type="text" name="username"></td>
</tr>
<tr>
      <td>Your Message:</td>
      <td><input type="text" name="message"></td>
</tr>
<tr>
      <td><input type="submit" value="Send Email"></td>
</tr>
</table>
</form>

</body>

</html>

And have your ASP page look like this(sendmail.asp):

<%
Dim username
Dim usermsg

username = request.form("username")
usermsg = request.form("message")

If len(trim(username))>0 Then

      Dim sfrom, sto, scc, sbcc, sSubject, Sbody

      sfrom = username
      sto = "Youremail@yourdomain.com"
      scc = ""
      sbcc = ""
      sSubject = "Email from " & username
      Sbody = Message
   Call Sendmail(Sfrom, Sto, Scc, Sbcc, Ssubject, sbody)

   function Sendmail(Sfrom, Sto, Scc, Sbcc, Ssubject, sbody)
      Dim MyMail
      Set MyMail = server.createobject("CDO.message")
      MyMail.From = sfrom
      MyMail.To = sTo
      MyMail.Cc = sCc
      myMail.bcc = Sbcc
      MyMail.Subject = Ssubject
      MyMail.textbody = sbody
      MyMail.send
      Set MyMail = nothing
   End Function
Else
      response.write "You did not enter a valid Name, click " & "<a href=""emailform.htm"">HERE</a>" & " to go back and reattempt to send a mail<br>thank you"
End If
%>

Try that out, remember this will only work with Win 2000 or later as otherwise you would use CDONTS and not CDO
0
 
mr_egyptianCommented:
Hey brycol24-

Your host is register.com? If so, which hosting plan are you under?
It appears that unless you have the "Web Hosting with eCommerce" you'll be limited to PHP or Perl.
0
 
TLBHCommented:
Ok if your limited to PERL Here is a basic script you can try out (Note this is using seperate HTML Page and a PERL Script- they could be combined but im gunna try keep this simple for ya)

replace the {stuff in these} with the actual locations / variables

HTML FILE (FORM SECTION ONLY)
-----------------------------------------------------------
<FORM Action={SCRIPTURL} METHOD=POST>
{Your form elements here- ENSURE THAT EACH HAS A NAME Property i.e.
<INPUT TYPE="Text" NAME={Name Goes Here}>
}
</FORM>

PERL FILE
This will need to be saved in your cgi-bin or a special PERL area check your host for details
----------------------------------------------------------
{Path to perl*}

#Use the CGI module that handles form input
use CGI qw/:standard/;

#read your data from the form
#Using scalar variables for simplicity
#NOTE: You should replace these with meaninfull
#names and replace the values in param with your
#OWN field names (you specified them in the form)
$var1=param('field1');
$var2=param('field2');
$var3=param('field3');
#etc etc

#Print a content type to allow output
print "Content-Type: text/html\n\n";

#once the values are read in- send the email
if (open(MAIL, "|/usr/bin/mini-sendmail -t")) {

#replace these with the email address you want to send to aswell as
#the address you want it to appear to come from
print MAIL "To: You@Email.Address\nFrom: You@Email.Address\n";

#Change the subject here if you wish
print MAIL "Subject: Web Form Data\n";

#again alter these to fit your form
print MAIL "Value 1: $var1 \n Value 2: $var2";

close(MAIL);

print <<"HTML Code";

email dispatched<BR>
<!-- ADD SOME HTML CODE HERE TO DISPLAY YOUR SUCCESS MESSAGE -->
HTML Code

} else {
print "error while sending email";
}


--------------------------------------------------------------------------------------
*PathTo Perl
Check with your webhost usually #!/usr/bin/perl or #!/usr/lib/bin/perl


note i havnt tested that code- any problems let me know

If you havnt used perl before the message INTERNAL SERVER ERROR usually means you have a syntax error - double check you typed your stuff correctly if it doesnt work post your customized code

Also note you need to change the permissions (CHMOD) of PERL files to 755 for them to be executable

Hope that helps
Peter


0
 
TLBHCommented:
sorry forgot to add that you need to check with your server the path to sendmail and update this line as appropriate:

#once the values are read in- send the email
if (open(MAIL, "|/usr/bin/mini-sendmail -t")) {
                                /\
                            YOUR SENDMAIL PATH HERE
0
 
TLBHCommented:
Thanks for the points- Were you able to adapt the code ok?
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 6
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now