 |
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

January 8th, 2009, 12:06 PM
|
Friend of Wrox
|
|
Join Date: Dec 2006
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
|
|
Static URL using CreateMHTMLBody
Chaps,
I have been using CDO.Message for a little while and once you add a few additional schemas it becomes a very useful tool.
The annoying issue i am having is with CreateMHTMLBody.
I am using an asp template page to produce the HTML mail body which again works well.
The issue is with the URL used to locate the template page. At present i can not find a way of locating the page without the full Static url location, eg:
Below with full URL
Below with non static URL - Errors
Code:
objMessage.CreateMHTMLBody("../mail.asp"& _
"?Un=" & UserName & ""& _
"&Um=" & UserEmail & "")
Is there is way of linking to the template page without using the full URL?
Any suggestions would be great.
Cheers
Aspless
|

January 8th, 2009, 06:29 PM
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
IME with CreateMHTMLBody you can not use a relative path.
It intrigues me why you would spend time trying to get a relative path working in this scenario. Any particular reason?
__________________
Wind is your friend
Matt
|
The Following User Says Thank You to mat41 For This Useful Post:
|
|

January 8th, 2009, 06:41 PM
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
|
|
You *could* create the absolute path, yourself, with only a bit of code.
Code:
server = Request.ServerVariables("SERVER_NAME")
curpage = Request.ServerVariables("URL")
curdir = Left( curpage, InStrRev(curpage,"/")-1 ) ' strip off file name
uponeDir = Left( curdir, InStrRev(curpage,"/")-1 ) ' same as ".."
absURL = "http://" & server & uponeDir & "/mail.asp"
objMessage.CreateMHTMLBody(absURL & "?Un=" & UserName & "&Um=" & UserEmail & "")
p.s.: That code *ASSUMES* that you are in a subdir and so you *CAN* do the "..". If you may or may not be in a subdir, you'd need to test for that second / [the first one will always be there].
|
The Following User Says Thank You to Old Pedant For This Useful Post:
|
|

January 8th, 2009, 07:14 PM
|
Friend of Wrox
|
|
Join Date: Dec 2006
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
|
|
The reason is a fairly simple one.
I use VMware for my development/IIS platform which runs all contained within the dev laptop i use.
For testing locally pre upload to live site, i use one objMessage.CreateMHTMLBody location for the VM server address and then need to change the address pre upload to the live server and test.
So far i have succeeded in not having any static links in the site with exception of the above.
Due to being able to include urn:schemas allows me to set priorities, Follow up flags and reply-by date/times, which makes useful admin notification emails for forgot password, call back and other notification emails.
So i intend on creating allot of static templates for each notification type - eg lot's of nice static url's to change.
It is more an administrational faf than an issue.
I can probably get around the issue by including an SQL reference which removes the need to use asp to any great length.
Is there any server variables that retrieve the full page URL? just a dim lit thought?
Addition to post - Thanks Old Pedant I'll have a look and try
Cheers
Aspless
Last edited by aspless; January 8th, 2009 at 07:18 PM..
|

January 8th, 2009, 07:39 PM
|
Friend of Wrox
|
|
Join Date: Dec 2006
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
|
|
Thanks guys.
That worked a treat.
Also adding InStrRev to my next google search.
Always good to learn new Instr functions.
Cheers
Aspless
|

January 8th, 2009, 07:43 PM
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
;;;For testing locally pre upload to live site, i use one objMessage.CreateMHTMLBody location for the VM server address and then need to change the address pre upload to the live server and test
Do you not use a global file for constants/variables etc? I use one for everything that changes from environment to environment, of course this eliminates the need to make alterations page to page. EG here are a couple of very useful ones:
inside global.asp:
Const URLBase = " http://someName.com/"
Const mailIP = "192.168.20.10"
now on all your pages your URL is of course:
URLBase
Doesnt HTTP_HOST get the full URL?
__________________
Wind is your friend
Matt
|
The Following User Says Thank You to mat41 For This Useful Post:
|
|

January 8th, 2009, 08:01 PM
|
Friend of Wrox
|
|
Join Date: Dec 2006
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
|
|
Honest answer is no.
I have not had as yet a need to specify global variables.
Thankfully i have not needed to include server specific configuarations to cdo mail so until now it was not a consideration.
I can see and have read before about good practise use of global variables.
Thanks for the reminder.
Cheers
Aspless
|

January 9th, 2009, 01:28 AM
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
|
|
Mat41: No, HTTP_HOST gives the same value as SERVER_NAME, except in some weird instances.
AspLess: No, there is no such server variable. Here's a dump of all the servervariables on one of my sites:
http://www.juncojunction.com/framitz.asp
AspLess: Oh, PLEASE! DO NOT USE GOOGLE to find keywords and such for a *LANGUAGE*! Use the REAL THING! The VBScript documentation! MUCH MUCH more compact! You can see it online, here:
http://msdn.microsoft.com/en-us/library/ms950396.aspx
Click on VBScript under "References".
Or, even better, download the full docs here:
http://www.microsoft.com/downloads/d...displaylang=en
The help file gives you a full index and search capabilities, all on your own machined. MUCH better than hassling with Google and HOPING you only have to look at 4 or 5 pages before you find the one that has what you need.
|
The Following User Says Thank You to Old Pedant For This Useful Post:
|
|

January 15th, 2009, 01:40 PM
|
Friend of Wrox
|
|
Join Date: Dec 2006
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
|
|
Old Pedant,
Thanks for the VBScript reference links.
Much quicker..
Cheers
Aspless
|
|
 |