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

Posted on 2011-03-17
Last Modified: 2012-05-11
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

Question by:colonelblue
LVL 30

Assisted Solution

by:Wayne Barron
Wayne Barron earned 83 total points
ID: 35162885
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.

Author Comment

ID: 35163308
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.
LVL 19

Accepted Solution

nschafer earned 334 total points
ID: 35169216
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.


Author Comment

ID: 35176166
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!
LVL 11

Assisted Solution

G_H earned 83 total points
ID: 35177402
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.

LVL 19

Assisted Solution

nschafer earned 334 total points
ID: 35180226

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,

Author Comment

ID: 35181919
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.
LVL 19

Assisted Solution

nschafer earned 334 total points
ID: 35182291
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.



Author Comment

ID: 35183001
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.
LVL 19

Assisted Solution

nschafer earned 334 total points
ID: 35183117
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.


Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question