We help IT Professionals succeed at work.

classic asp 3.0 an email

Webboy2008
Webboy2008 used Ask the Experts™
on
I would like to have a link (url) like
<a href=testing.asp?id=1>Test</a>
Once the user is clicked, a pdf document will be generated, and value of ID in url will be inserted into the pdf document, and then automatically attached with a default client email.

Is it possible?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
All of that is possible with classic ASP but one requirement to make it happen is some serverside software on your host/server that generates the PDF, this cannot be done with ASP/VBscript.

/ Tobzzz

Author

Commented:
First of all thank. if you know which software will work that will be great.

However, I believe we don't be allowed to install anything at this time. but it is good to know which one is available.

Thanks
Top Expert 2007

Commented:
You can use JavaScript on the server, and it should not require installation.

I use IIS, though, so YMMV.

Commented:
I think there's a few, aspPDF, PDFDoc Scout, abcPDF etc. Best to ask your hosting company what/if they have anything. I haven't done this myself but would really like to hear how it can be achieved ith JavScript, I was unaware you could do that.
Top Expert 2007

Commented:
The following code is part of a larger classic ASP page. It uses built-in objects and no third-party tools.

It isn't heavily documented, but should be a starting point for you.


	function set_retval(arg) {
		// Handles return value and error object creation
		return function(arg){
			var how = arg || {};
			return {
				'cap'	:how.cap	|| 'ok', 
				'result':how.result || '', 
				'error'	:how.error	|| '',
				'extra'	:how.extra	|| '' 
			};
		}();
	}

	function send_mail(req, from) {
		// Expects
		//
		// req
		//	.email		To email address
		//	.subject	Subject line
		//	.text		Message text
		
		if (String(Request.ServerVariables('HTTP_HOST')).indexOf('localhost') === 0) {
			return send_mail_localhost(req);
		}
		
		var source = 'send_mail',
			retval = set_retval(),
			err = {},
			schema = 'http://schemas.microsoft.com/cdo/configuration/',
			config = new ActiveXObject('CDO.Configuration'),
			msg = new ActiveXObject('CDO.Message'),
			ra = Session('login').split('|'),
		//
		exknob;
		
		// No "bare" line breaks
		req.email = req.email.replace(/\n/g,'\r\n');
		req.subject = req.subject.replace(/\n/g,'\r\n');
		req.text = req.text.replace(/\n/g,'\r\n');
		
		try {
			config.Fields.Item(schema + 'sendusing') = 2; // cdoSendUsingPort
			config.Fields.Item(schema + 'smtpserver') = 'relay-hosting.secureserver.net';
			
			config.Fields.Update();
			
			msg.Configuration = config;
			
			msg.From = (from) ? from : 'yoohoo@yahoo.com'; // Your email address
			msg.To = req.email;
			msg.Subject = req.subject;
			msg.TextBody = req.text;
			msg.Send();
		}
		catch(e) { 
			retval.cap = 'error';
			retval.description = 'cannot send email';
			retval.error = e.description;
		}
		return retval;
	}

Open in new window

Top Expert 2007

Commented:
As for the PDF part...that is another matter. The following link describes one possible solution:

http://www.15seconds.com/issue/990902.htm

although it requires registration of two DLLs on the server, which might be a problem.

You might contact your ISP and ask them what they suggest you do? Otherwise, you might be out of luck.

UNLESS a PDF is just for convenience? Can you use any other type of file as the attachment? Do you have to create a PDF?
Mark FranzProject Manager

Commented:
Create a RTF file instead, http://support.microsoft.com/kb/270906  No objects or component registration required...

Sending attachments with CDO.Message is a simple procedure too.

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.AddAttachment "../inetroot/docs/test.doc"
myMail.Send
set myMail=nothing
%>

Author

Commented:
Badotz:

1. Does the code include attachment ?
2. Can you send me sample codes (how to call the function...)

Thanks,

Author

Commented:
mgfranz:Create a RTF file instead does not work for us in this case. We need to attach as pdf.

Thanks
Mark FranzProject Manager

Commented:
Unless you have the required components registered on your hosting server this is not possible.  Check with your host to see if they have a PDF solution already installed.

If you were on .NET this would be easier...

Author

Commented:
What Components you suggest?
Ricky
Top Expert 2007

Commented:
1. No, but using the example from http:#a33154191 should help.
2. It is invoked from the browser via Ajax, code to follow...

Author

Commented:
Badotz: 1: I don't know how to get it together working in html.
Can you please help?
Mark FranzProject Manager

Commented:
There are a number of PDF creation components available, here is a simple search result

http://www.google.com/search?q=asp+form+to+PDF&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
Top Expert 2007

Commented:
Probably not this week, sorry - too much work to do. I'll try and cobble something together, but I must warn you: it isn't for the faint of heart.

Author

Commented:
mgfranz: I research all in this afternoon, and none match what i need.

Mark FranzProject Manager

Commented:
I find that an interesting comment since all you are doing is passing a form value to the PDF form.  Most all of the ASP > PDF components out there will allow a form insertion of a value.  Once the PDF is created, attaching it to a CDO mail routine should be moot.

Unless I'm missing something...

Author

Commented:
I got what you mean.
1. Which Components you suggested for classic asp?
2. I use FDF to insert the data into PDF, and add asp codes to attach as you suggested.
However, the email receiver get FDF file instead of PDF.

Thanks
Mark FranzProject Manager

Commented:
There in lies the need for a .dll component that can be registered on the server, pure ASP cannot process FDF files to PDF without using any number tools available.  Check with your IT or host to see if they have any PDF generator components already installed.  CutePDF is the de facto standard for free pdf creation.
Top Expert 2007

Commented:
Pretty much what I said in http:#a33154124...
Project Manager
Commented:
Yup.  This has been an issue for well over 10 years...  At least in .net its easier...