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

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

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,


  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", "", False

  ' Actually Sends the request and returns the data:
  dim smtpServer, smtpUser, smtpPassword
  dim strFrom, strTo, strSubject, strHTML
  dim oMail, oMailconf
  smtpServer = "Your SMTP Server"  
  ' SMTP Credentials if needed
  '  smtpUser = "" 
  '  smtpPassword = ""
  strFrom = ""
  strTo = ""
  strSubject = "Message Subject"
  set oMail = Server.CreateObject("CDO.Message") 
  Set oMailconf = Server.CreateObject ("CDO.Configuration") 
  ' Outgoing SMTP server 
  oMailconf.Fields("") = SMTPServer
  oMailconf.Fields("") = 25 
  oMailconf.Fields("") = 2
  oMailconf.Fields("") = 60 
  if strUser > "" then
    oMailconf.Fields("") = 1     ' Basic (Clear Text) Authentication
    oMailconf.Fields("") = 1               ' Basic (Clear Text) Authentication
    oMailconf.Fields("") = SMTPPassword        ' SMTP Password
    oMailconf.Fields("") = SMTPUser            ' SMTP User Name
  end if
  oMail.Configuration = oMailconf
  oMail.HTMLBody = xml.responseText
  oMail.From = strFrom
  oMail.To = strTo
  oMail.Subject = strSubject
  Set xml = Nothing
  set oMail = Nothing

Open in new window

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 ("") = 2 'Send the message using the network (SMTP over the network).
myMail.Configuration.Fields.Item ("") =""
myMail.Configuration.Fields.Item ("") = 25
myMail.Configuration.Fields.Item ("") = false 'Use SSL for the connection (True or False)
myMail.Configuration.Fields.Item ("") = 60
' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
myMail.Configuration.Fields.Item ("") = 1 'basic (clear-text) authentication
myMail.Configuration.Fields.Item ("") =""
myMail.Configuration.Fields.Item ("") ="********"

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&""
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.
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.CreateMHTMLBody ""
set myMail=nothing

Open in new window

But it adds an attachment to the email. It adds a txt file with strnge text.
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. "" as opposed to "/images/happy.jpg"?
Will that work?

Thank you again!
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.

nschaferConnect With a Mentor Commented:

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

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

Hope this helps,
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.
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", "", False

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


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.
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.

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.