Can you send an ASP page with parameters embedded in an email?

I am using ASP Classic and have seen solutions using CDONTS for embedding html into email but is it possible to send an asp page with parameters.
For example: embed a page  http://www.myfdomain.com/page.asp?ID=7



colonelblueAsked:
Who is Participating?
 
nschaferConnect With a Mentor Commented:
So you don't want to send them a link, you want to send them the results of the ASP page?

The xmlhttp code below is from http://www.4guysfromrolla.com/webtech/110100-1.shtml

Try something like the code below.  Images from the web page probably won't show in the e-mail because the code is simply pulling the HTML from the specified page and the image path usually provided is not the full path to the image, it is the relative path.  Since the e-mail doesn't have a full path to the image it can't download it.  

Hope this helps,

Neal.

<%
  Response.Buffer = True
  Dim objXMLHTTP, xml
  Dim body

  ' Create an xmlhttp object:
  Set xml = Server.CreateObject("Microsoft.XMLHTTP")
  ' Or, for version 3.0 of XMLHTTP, use:
  ' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
  ' Opens the connection to the remote server.

  ' This is where you put the address of the web page you want to send
  xml.Open "GET", "http://www.w3schools.com/asp", False

  ' Actually Sends the request and returns the data:
  xml.Send
 
  dim smtpServer, smtpUser, smtpPassword
  dim strFrom, strTo, strSubject, strHTML
  dim oMail, oMailconf
  smtpServer = "Your SMTP Server"  
  ' SMTP Credentials if needed
  '  smtpUser = "" 
  '  smtpPassword = ""
  strFrom = "From@yourdomain.com"
  strTo = "Someone@somewhere.com"
  strSubject = "Message Subject"
  set oMail = Server.CreateObject("CDO.Message") 
  Set oMailconf = Server.CreateObject ("CDO.Configuration") 
  ' Outgoing SMTP server 
  oMailconf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
  oMailconf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
  oMailconf.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  oMailconf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 
  if strUser > "" then
    oMailconf.Fields("http://schemas.microsoft.com/cdo/configuration/CdoProtocolsAuthentication") = 1     ' Basic (Clear Text) Authentication
    oMailconf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1               ' Basic (Clear Text) Authentication
    oMailconf.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SMTPPassword        ' SMTP Password
    oMailconf.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = SMTPUser            ' SMTP User Name
  end if
  oMailconf.Fields.Update 
  oMail.Configuration = oMailconf
  oMail.HTMLBody = xml.responseText
  oMail.From = strFrom
  oMail.To = strTo
  oMail.Subject = strSubject
  oMail.Send()
  Set xml = Nothing
  set oMail = Nothing
%>

Open in new window

0
 
Wayne BarronConnect With a Mentor Author, Web DeveloperCommented:
What are you wanting to send?
Use CDOSYS instead of CDONTS.
You have create the html ASP Generated BODY of the message out.
This is an Example of an email that will send out the Variables that are created in the page.

<%
Set myMail = CreateObject("CDO.Message") 
     
'This section provides the configuration information for the remote SMTP server.
     
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.domain.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = false 'Use SSL for the connection (True or False)
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="webmaster@domain.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="********"
     
myMail.Configuration.Fields.Update

MyFirst = "This is my 1st"
MySecond = "This is my 2nd"
MyThird = "This is my 3rd"
MyForth = "This is my 4th"
MyFifth = "This is my 5th"

myMail.HTMLBody = "This is my message with Parameters added to the message"
myMail.HTMLBody = myMail.HTMLBody &"This is the First Parameter: "&MyFirst&""
myMail.HTMLBody = myMail.HTMLBody &"This is the Second Parameter: "&MySecond&""
myMail.HTMLBody = myMail.HTMLBody &"This is the Third Parameter: "&MyThird&""
myMail.HTMLBody = myMail.HTMLBody &"This is the Forth Parameter: "&MyForth&""
myMail.HTMLBody = myMail.HTMLBody &"This is the Fifth Parameter: "&MyFifth&""
myMail.Send
set myMail = nothing
%>

Open in new window


Just add in your Codes as described above, and it will be sent out.

Good Luck
Time for sleep now.
Carrzkiss
0
 
colonelblueAuthor Commented:
Thank you but I do not understand.

I was able to use something like this:
 
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.CreateMHTMLBody "http://www.w3schools.com/asp/"
myMail.Send
set myMail=nothing
%>

Open in new window

But it adds an attachment to the email. It adds a txt file with strnge text.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
colonelblueAuthor Commented:
Hello nschafer,

That seems to work real nice.
I really need to get those images to show too. Is there a workaround?
What if I made all the images and links to those pages with full paths
I.e. "http://www.domain.com/images/happy.jpg" as opposed to "/images/happy.jpg"?
Will that work?

Thank you again!
0
 
G_HConnect With a Mentor Commented:
Hi, yes that will work, but most email programs will ask the user to accept the image download.

You can embed the images in the email, as attachments to get around this if you want.

GH
0
 
nschaferConnect With a Mentor Commented:
Yes,

you can embed the images.  If you do that then you will want to change the image to <img src="happy.jpg" alt="Happy Birthday"/>

add the following line before the oMail.Send() line to add an image:

oMail.AddRelatedBodyPart "physical path to happy.jpg", "Happy.jpg", 0

example:
oMail.AddRelatedBodyPart "C:\images\happy.jpg", "Happy.jpg", 0

Hope this helps,
Neal.
0
 
colonelblueAuthor Commented:
Hey guys and thanks.
I think they'd prefer that there be no attachments and have the Email Program ask for a download.

In that case  I would then have to make all my links and images with full paths, right?

At the moment my pages  are in a passworded site in IIS. So when I try to send a page it says Access is denied and does not send anything.
Is there a parameter that I can temporarily add to the code to add the login and pass for now until I move it all into a public production setting?

Sincere thanks.
0
 
nschaferConnect With a Mentor Commented:
you could have your page look for a UserName and Password as part of the QueryString.  You could then add these to the code above:

  xml.Open "GET", "http://www.yoursite.com/yourpage.asp?user=username&pass=password", False

Since this is just for a temporary solution I think that should work for you.

Neal.



0
 
colonelblueAuthor Commented:
Hey Neal thank you.
One more question if I may.
Providing I make all links with full paths, do you know if jquery functions will work when opened in the email client?

Thanks again.
0
 
nschaferConnect With a Mentor Commented:
I don't know.  I expect that will be up to the mail client to some extent.  I don't think that most mail clients will allow scripting in the html, so my guess would be that it won't work, but not having tried it I really can't say for sure.

Neal.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.