• 0

ASP Help?


Question

I'm tryin to make this Sendmail code to send the result of a form to an e-mail, kinda like a contact form. Its been a long time since I've done this and i've lost my touch. could someone help me out?

<%
 ?Dim email, name, age, grade, address, phone, email, mom, dad
 ?Dim Mailer
 ?
 ?Set Mailer = Server.CreateObject("SMTPsvg.Mailer") ?'create Mailer object
 ?email = Request.QueryString("email") ? ' Get e-mail from querystring/form
 ?name = Request.QueryString("frstname") & " " Request.QueryString("lstname") ' Get name from querystring/form
 ?age = Request.QueryString("age")
 ?
 ?Mailer.FromName ? = name ?
 ?Mailer.FromAddress= "contactus@lala.com
 ?Mailer.RemoteHost = "smtp.lala.com" ?'Name of your mail host
 ?Mailer.AddRecipient "LALA Employee", personatthrive@lala.com 'Recipient
 ?Mailer.Subject ? ?= "Contact E-mail"
 ?Mailer.BodyText ? = "E-mail : " & email & "Name: " & name
 ?Mailer.SendMail ?'Send mail
 ?Set Mailer = Nothing
%>

That isn't complete, but I'm confused of where to go from there. It supposed to send the following fields to an e-mail, either formated with HTML or plain text

Fields:

First Name

Last Name

Age

Grade

Address

City

State

Zip

Phone

E-Mail

Mother's Name

Father's Name

Programs (Array of 6)

Thanks

splendore0@msn.com

Link to comment
https://www.neowin.net/forum/topic/279433-asp-help/
Share on other sites

11 answers to this question

Recommended Posts

  • 0
  Vafer1 said:
I'm tryin to make this Sendmail code to send the result of a form to an e-mail, kinda like a contact form. Its been a long time since I've done this and i've lost my touch. could someone help me out?

<%
  Dim email, name, age, grade, address, phone, email, mom, dad
  Dim Mailer
  
  Set Mailer = Server.CreateObject("SMTPsvg.Mailer")  'create Mailer object
  email = Request.QueryString("email")   ' Get e-mail from querystring/form
  name = Request.QueryString("frstname") & " " Request.QueryString("lstname") ' Get name from querystring/form
  age = Request.QueryString("age")
  
  Mailer.FromName   = name  
  Mailer.FromAddress= "contactus@lala.com
  Mailer.RemoteHost = "smtp.lala.com"  'Name of your mail host
  Mailer.AddRecipient "LALA Employee", personatthrive@lala.com 'Recipient
  Mailer.Subject    = "Contact E-mail"
  Mailer.BodyText   = "E-mail : " & email & "Name: " & name
  Mailer.SendMail  'Send mail
  Set Mailer = Nothing
%>

That isn't complete, but I'm confused of where to go from there. It supposed to send the following fields to an e-mail, either formated with HTML or plain text

Fields:

First Name

Last Name

Age

Grade

Address

City

State

Zip

Phone

E-Mail

Mother's Name

Father's Name

Programs (Array of  6)

Thanks

splendore0@msn.com

585397104[/snapback]

You need to get the Form information from the Request object's Form collection. Then you can access the Form's fields by name/id.

Link to comment
https://www.neowin.net/forum/topic/279433-asp-help/#findComment-585397901
Share on other sites

  • 0

It's the same most of the time, if you are sending it to a webmail based system like Hotmail, it automatically will strip that part and just display the <BODY>, in Outlook and those ones, the complete file is parsed with <HTML> existing or not, so I recommend you to send a complete <HTML> document and if you are putting CSS styles in the mail put them to be inline because most of the time the <HEAD> part is stripped out in websystems and local ones..

Link to comment
https://www.neowin.net/forum/topic/279433-asp-help/#findComment-585414104
Share on other sites

  • 0

ANYONE see anything wrong?

[/code]<% Dim email, name, age, grade, addy, phone, email, mom, dad

Dim Mailer

Set Mailer = Server.CreateObject("SMTPsvg.Mailer") 'create Mailer object

email = Request.QueryString("email") ' Get e-mail from querystring/form

' name = Request.QueryString("frstname") & " " 'Request.QueryString("lstname") ' Get name from querystring/form

' age = Request.QueryString("age")

Mailer.FromName = "Jeff Greener"

Mailer.FromAddress= "contactus@lala.com"

Mailer.RemoteHost = "smtp.cox.net" 'Name of your mail host

Mailer.AddRecipient "LALA Employee", "splendore0@msn.com" 'Recipient

Mailer.Subject = "Contact E-mail"

Mailer.BodyText = "<html>

<head>

<title>E-Mail from website </title>

</head>

<body>

<p>First Name: " & frstname & "<br>

Last Name: " & lstname & "<br>

Age: " & age &"<br>

Grade: " & grade & "<br>

Address: " & addy & "<br>

City: " & city & "<br>

State: " & state & "<br>

Zip: " & zip & "<br>

Phone: " & phone &"<br>

E-Mail: " & email & "<br>

Mother's Name: " & mname & "<br>

Father's Name: " & fname & "</p>

</body>

</html>"

Mailer.SendMail 'Send mail

Set Mailer = Nothing

%>


I can't figure it out, i thought i was doing it right but i think im wrong....

Link to comment
https://www.neowin.net/forum/topic/279433-asp-help/#findComment-585437534
Share on other sites

  • 0

The biggest problem with this is that you cannot have line breaks within your body text.

You can do:

Mailer.BodyText = "&lt;html&gt;&lt;head&gt;&lt;title&gt;E-Mail from website &lt;/title&gt;&lt;/head&gt;&lt;body&gt;..." 

so that the body text is all on one line.

OR

you can do:

Dim strBody

strBody = ""
strBody = strBody "&lt;html&gt;"
strBody = strBody "  &lt;head&gt;"
strBody = strBody "    &lt;title&gt;E-Mail from website &lt;/title&gt;"
strBody = strBody "  &lt;/head&gt;"
strBody = strBody "  &lt;body&gt;"... 

Mailer.BodyText = strBody

Try this and let me know if this work or if you are still encountering problems.

Link to comment
https://www.neowin.net/forum/topic/279433-asp-help/#findComment-585439706
Share on other sites

  • 0

&lt;% Dim email, name, age, grade, addy, phone, email, mom, dad
 Dim Mailer

 Set Mailer = Server.CreateObject("SMTPsvg.Mailer")  'create Mailer object
 email = Request.QueryString("email")   ' Get e-mail from querystring/form
 name = Request.QueryString("frstname") &amp; " " Request.QueryString("lstname") ' Get name from querystring/form
 age = Request.QueryString("age")


 Mailer.FromName   = name  
 Mailer.FromAddress= "contactus@lala.com"
 Mailer.RemoteHost = "smtp.cox.net"  'Name of your mail host
 Mailer.AddRecipient "LALA Employee", "splendore0@msn.com" 'Recipient
 Mailer.Subject    = "Contact E-mail"
 Mailer.BodyText   = "&lt;html&gt;&lt;head&gt;&lt;title&gt;E-Mail from website &lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;First Name: " &amp; frstname &amp; "&lt;br&gt;Last Name: " &amp; lstname &amp; "&lt;br&gt;Age: " &amp; age &amp;"&lt;br&gt;Grade: " &amp; grade &amp; "&lt;br&gt;Address: " &amp; addy &amp; "&lt;br&gt;City: " &amp; city &amp; "&lt;br&gt;State: " &amp; state &amp; "&lt;br&gt;Zip: " &amp; zip &amp; "&lt;br&gt;Phone: " &amp; phone &amp;"&lt;br&gt;E-Mail: " &amp; email &amp; "&lt;br&gt;Mother's Name: " &amp; mname &amp; "&lt;br&gt;Father's Name: " &amp; fname &amp; "&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;"
 Mailer.SendMail  'Send mail
 Set Mailer = Nothing
%&gt;

Whats wrong now? still server error, could it be the content type? anyone remember the mailer. extension for it?

Link to comment
https://www.neowin.net/forum/topic/279433-asp-help/#findComment-585454018
Share on other sites

  • 0

Your missing an "&" between the " " and Request.QueryString("lstname") :

 name = Request.QueryString("frstname") &amp; " " Request.QueryString("lstname")

Should be:

 name = Request.QueryString("frstname") &amp; " " &amp; Request.QueryString("lstname")

If this still doesn't fix it, do you know what the error is or are you just getting the "Page Cannot Be Displayed Error?" If the latter, than have you tried injecting any error catching to display where the error might be occuring?

Oh, try adding this code to catch any smpt errors:

 Mailer.SMTPLog = "c:\smtplog.txt"

Link to comment
https://www.neowin.net/forum/topic/279433-asp-help/#findComment-585458350
Share on other sites

  • 0

I am getting ERROR 500, internal server error. Put that fix in and still doesnt work..

Does anyone have the resources to test this page on their site?

And the smptlog doenst create even after changing permissions,

THis is all my server log says...

[sat Feb 12 21:59:52 2005] [error] [client 68.98.23.118] File does not exist: /home/kentco2/public_html/500.shtml

[sat Feb 12 21:58:57 2005] [error] [client 68.98.23.118] File does not exist: /home/kentco2/public_html/500.shtml

[sat Feb 12 21:58:57 2005] [error] [client 68.98.23.118] File does not exist: /home/kentco2/public_html/404.shtml

and yes ASP is enabled.

Link to comment
https://www.neowin.net/forum/topic/279433-asp-help/#findComment-585461999
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • The sound never left. My Windows 10 installation still has it enabled, I found the checkbox in an earlier build and turned it on and my PC chimes every time it cold boots. That's how I know Windows Update didn't shut down after updating despite me telling it to. That being said... seeing Apple Liquid Glass has me thinking, if Windows 11 brought back the 7 Aero Glass running on top of the new kernel, minus the AI crap, I might actually be willing to move to it.
    • These days the differences are small, so if you're a petty nerd over dumb things, you'll be forever stuck behind and won't ever enjoy the latest and current niceties. Yup, it's a real life lesson too.
    • Microsoft 365 Roadmap Weekly: New features for the new Outlook, Copilot updates and more by David Uzondu This week, Microsoft added a slew of new entries to the public Microsoft 365 Roadmap, including plans for Teams, the new Outlook, and, of course, Copilot and Copilot Chat. Starting with Outlook, three practical updates are headed for the new Outlook for Windows client. First up, you'll finally be able to add attachments to emails while you are offline, a basic function that has been sorely missed. The remaining two features are slated for August. One will let you create a rule that specifically triggers a desktop alert. The other adds a folder deletion warning. If you try to delete a folder on which an email rule depends, Outlook will stop you and prompt you to fix the rule first. Like Google with Gemini, Microsoft continues to push Copilot deeper into its applications, with several updates planned for mid-2025. Later this month, Copilot will be able to give you a quick summary of recent changes and comments on a file right from the backstage view in Word, Excel, and PowerPoint, before you even open the document. Also, Copilot Chat will get the ability to limit its responses to selected content sources, like specific SharePoint sites or files, which should make its answers more focused. Next month, PowerPoint users will get two more Copilot tricks. You will be able to rewrite selected text using a custom natural language prompt and add entirely new topics to an existing presentation, with Copilot generating slides that match the existing look and feel. Edge is not left out, as its integrated Copilot Chat will soon be able to access content across multiple open tabs, not just the active one, with that update scheduled for August. Finally, for organizations that heavily use Teams Rooms Pro on Windows, an August update will allow for simultaneous town hall and webinar views. This will keep the presenter's backstage controls, like green room and backroom chat, hidden from the main audience display in the room.
    • The only reason I have Windows 11 is because it came with the new machine. I was quite happy with Windows 10. Windows 11 has its own issues just like any OS, but honestly after the fear-mongering towards Windows 11 while I was on Windows 10, I thought I would be more frustrated. I still prefer my daily OS, but Windows 11 isn't the worst thing in the world for what I use it for.
  • Recent Achievements

    • Apprentice
      Wireless wookie went up a rank
      Apprentice
    • Week One Done
      bukro earned a badge
      Week One Done
    • One Year In
      Wulle earned a badge
      One Year In
    • One Month Later
      Wulle earned a badge
      One Month Later
    • One Month Later
      Simmo3D earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      610
    2. 2
      ATLien_0
      285
    3. 3
      +FloatingFatMan
      179
    4. 4
      Michael Scrip
      151
    5. 5
      Steven P.
      112
  • Tell a friend

    Love Neowin? Tell a friend!