Solved

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

Posted on 2011-03-17
10
444 Views
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  http://www.myfdomain.com/page.asp?ID=7



0
Comment
Question by:colonelblue
10 Comments
 
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 ("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
 

Author Comment

by:colonelblue
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.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
 
LVL 19

Accepted Solution

by:
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 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
 

Author Comment

by:colonelblue
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. "http://www.domain.com/images/happy.jpg" as opposed to "/images/happy.jpg"?
Will that work?

Thank you again!
0
 
LVL 11

Assisted Solution

by:G_H
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.

GH
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 19

Assisted Solution

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

Author Comment

by:colonelblue
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.
0
 
LVL 19

Assisted Solution

by:nschafer
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", "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
 

Author Comment

by:colonelblue
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.
0
 
LVL 19

Assisted Solution

by:nschafer
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.

Neal.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now