PDA

Click to See Complete Forum and Search --> : Can this be done!?


turfbult
Jun 6th, 2001, 02:42 AM
Hello,

I want to dynamicaly create a HTML page/file and then send it as an attachment using
ASPMail. Can it be done.

Let's use this example



strbody = "<html>"
strbody = strbody & "<body>"
strbody = strbody & "<p>Testing, testing 123</p>"
strbody = strbody & "</body>"
strbody = strbody & "</html>"



This, I now want to send as an attachment called "test.html"

Can this be done??

Thanks,
T

alex_read
Jun 6th, 2001, 03:10 AM
I'm not too sure what ASPMail is, but I cheated when I needed tihs done :

strbody = "<html>"
strbody = strbody & "<body>"
strbody = strbody & "<p>Testing, testing 123</p>"
strbody = strbody & "</body>"
strbody = strbody & "</html>"

Open "C:\TempInternetFile.htm" for output as #1
'creates a htm file on your pc
print #1, strbody
Close #1

Send Mail with ASPMail here ...

Kill "C:\TempInternetFile.htm"

I used Outlook when I did this, so for the sending / attaching part you're after this I can't help with ...

turfbult
Jun 6th, 2001, 03:38 AM
Thanks Alex,

I know that this code works in VB, but does it work in ASP.



<%

strbody = "<html>"
strbody = strbody & "<body>"
strbody = strbody & "<p>Testing, testing 123</p>"
strbody = strbody & "</body>"
strbody = strbody & "</html>"

Open "C:\TempInternetFile.htm" for output as #1
'creates a htm file on your pc
print #1, strbody
Close #1

Send Mail with ASPMail here ...

Kill "C:\TempInternetFile.htm"


%>



I get this error...

Open "C:\TempInternetFile.htm" for output as #1
-------------------------------^

Am I doing something wrong??

Thanks,
T

alex_read
Jun 6th, 2001, 03:56 AM
It works in vbs, but have just tried in asp & can't for the life of me figure why this is the case.

Take a look at the FileSystemObject as a workaround as you can create text files and write to them via this.

Bloody confusing though ! :eek: :confused:

turfbult
Jun 6th, 2001, 04:19 AM
Thanks, I'll try and figure it out.

T

alex_read
Jun 6th, 2001, 04:27 AM
the 2 methods you're gonna need to look at are :

Dim Fso As New FileSystemObject

Fso.CreateTextFile "C:\TempInternetFile.htm"
Fso.OpenTextFile "C:\TempInternetFile.htm"
Take a look at this page for more help : http://msdn.microsoft.com/scripting/vbscript/doc/sgworkingwithfiles.htm