Click to See Complete Forum and Search --> : Emailing a User using ASP


mcleod
06-17-2005, 08:56 AM
Hi All

I'm trying to create an ASP page that will Email a user an advert. I'm using CDONTS to do this and so far have got my page sending basic Email with a couple of images.

However it is quite a large advert with images, different font styles, and table styles. Is it possible to use a style sheet for this, or does it all have to be done inline?! Also since I'm basically copying an existing page, is it at all possible to use that pages source so I don't have to re-write it all the time?!

Any help with this would be much appreciated.

Cheers

Ross

phpnovice
06-17-2005, 01:55 PM
You can execute other pages from within a current page as follows:

Server.Execute(page_name)

The format of the BODY content of your email is going to be dictated by the HTML support of the target email client. Not all email clients are created equal. Thus, I would not expect style sheets to be supported.

wmif
06-17-2005, 02:46 PM
if css is supported you would need to have the styles defined inside the page and not linked to on a remote .css file. with that remote css file it would need to contact the servers to download and some email clients dont like that.

mcleod
06-20-2005, 04:32 AM
Thanks for the advice, I tried using the Server.Execute(page_name) this shows the page on screen but it does not Email it :-(

This is the code I'm using:

<html>
<head>
<title>Hello World</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
</head>

<body>
<%
Dim objCDOMail
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.From = "website@pars.co.uk"
objCDOMail.To = "ross.mcleod@pars.co.uk"
objCDOMail.Subject = "Enquiry sent from my web site"
objCDOMail.BodyFormat = 0
objCDOMail.MailFormat = 0
objCDOMail.Body = server.Execute("printer.htm")
objCDOMail.Importance = 1
objCDOMail.Send
Set objCDOMail = Nothing
%>
</body>
</html>

I'm I working along the right path or have I got to put the html code in the objCDOMail.Body line?!

phpnovice
06-20-2005, 09:26 AM
You cannot do this:

objCDOMail.Body = server.Execute("printer.htm")

Server.Execute (http://msdn.microsoft.com/library/en-us/iissdk/html/db562da1-d49d-4fe5-9747-64ef530de23f.asp) is not a function that returns a value in that manner. Instead, it is much like an SSI #include statement. The advantage being that Server.Execute more easily lends itself to logical structures -- such as the following:

Select Case test_variable
Case 'value1'
Server.Execute some_page1.asp
Case 'value2'
Server.Execute some_page2.asp
Case 'value3'
Server.Execute some_page3.asp
Case Else
Server.Execute some_page0.asp
End Select