Go Premium for a chance to win a PS4. Enter to Win

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

need form mail for asp site (NT)

hi - I just transferred a website from one host to another. Its a windows based site using .asp files.  I need to get the form mail to work. Last provider had ASPMail component, this new host does not have any component and email is with a third party host - I have a plesk control web panel. anyone know how i can get form mail to work here?

using a test script i found online here:
http://www.brainjar.com/asp/formmail/
but unable to get that to work. Any advise would be great!
0
WebGirlCrissy
Asked:
WebGirlCrissy
  • 2
  • 2
1 Solution
 
Scott Fell, EE MVEDeveloperCommented:
You just need to use cdo.  This is a great resource.  http://www.paulsadowski.com/wsh/cdo.htm

You can start with this

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "yea mail"
objMessage.From = "me@my.com"
objMessage.To = "test@mydomain.com"
' objMessage.TextBody = "This is some sample message text."
objMessage.HTMLBody = "<h1>This is some sample message html.</h1>"
objMessage.Send

If you are on a shared host, chances are this might work.  If you need to use a remote smtp or authorize with a password check out the example, "Sending a text email using authentication against a remote SMTP server."

You might have to do a few trial and errors to get the correct settings.  I would try the simple version first.  If that does not work, you can try and ask your web host which settings will work for cdo email.  If you are using a remote smtp service then you could probably just use the given sample for remote but make sure you have the username, password, host, and port set.
0
 
WebGirlCrissyAuthor Commented:
that worked like a charm! thank you!
0
 
WebGirlCrissyAuthor Commented:
thank you!
0
 
Scott Fell, EE MVEDeveloperCommented:
Great.  

In order to make this easy for me on multiple pages I keep this code on a separate page as a function and add it as an in include file on any page I need to send mail.

function SendMail(from,to,subject,body)

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = subject
objMessage.From = from
objMessage.To = to
' objMessage.TextBody = "This is some sample message text." 
objMessage.HTMLBody = body
objMessage.Send 

end function

Open in new window


Sometimes  I get really fancy and have a separate template file where I keep things like the header, footer, background etc that is also in a separate include file.
function template(body)
html="<table><tr><td>header</td></tr>"
html=html&"<table><tr><td>"&body&"</td></tr>"
html=html&"<table><tr><td>footer</td></tr>"
template=html
end function

function SendMail(from,to,subject,body)

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = subject
objMessage.From = from
objMessage.To = to
' objMessage.TextBody = "This is some sample message text." 
objMessage.HTMLBody = template(body)
objMessage.Send 

end function

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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