Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Generating email with attached document

Author  Topic 

nickmurphy
Starting Member

2 Posts

Posted - 2008-02-29 : 12:02:31
Hi everyone!

I'm new to the forum and my use of SQL is primarily for my company's Exact Macola Progression series accounting system. I'm wanting to do something that I feel may be fairly simple to those who know what they're doing...or maybe not.

Basically when our staff creates purchase orders, they are printed to a PDF document with the syntax of "PO####.pdf" and saved to a shared directory on the network. I would like to create a procedure to email these PDF documents when the order is generated. The PO number is in the SQL record, and the directory to which the PDFs are saved is fixed. The email address could be taken from existing vendor records or a new table/spreadsheet that I could maintain with the vendor number and corresponding email address. Only one email address per vendor will be needed, so it should be fairly simple. This procedure could run perhaps once per hour or something similar.

Can anyone point me in the right direction on this one?

Thank you!
Nick

davydcarr
Starting Member

2 Posts

Posted - 2008-03-01 : 14:58:54
You could create a stored procedure that would run as a scheduled job, and in the procedure extract the data from the tables as needed and use one the stored procedures that send mail like:

SELECT @PoNumber FROM tblPO WHERE EmailSent IS NULL

SET @File = 'Static folder path\PO' + @PONumber + '.PDF'

EXEC sp_send_cdontsmail @From=@EmailFrom, @To=@Email, @Subject=@EmailSubject, @Body=@EmailBody, @Attach=@File

or

EXEC sp_send_cdosysmail @From=@EmailFrom, @To=@Email, @Subject=@EmailSubject, @Body=@EmailBody, @Attach=@File

Cheers,


~Dave
Go to Top of Page

nickmurphy
Starting Member

2 Posts

Posted - 2008-03-02 : 17:14:07
quote:
Originally posted by davydcarr

You could create a stored procedure that would run as a scheduled job, and in the procedure extract the data from the tables as needed and use one the stored procedures that send mail like:

SELECT @PoNumber FROM tblPO WHERE EmailSent IS NULL

SET @File = 'Static folder path\PO' + @PONumber + '.PDF'

EXEC sp_send_cdontsmail @From=@EmailFrom, @To=@Email, @Subject=@EmailSubject, @Body=@EmailBody, @Attach=@File

or

EXEC sp_send_cdosysmail @From=@EmailFrom, @To=@Email, @Subject=@EmailSubject, @Body=@EmailBody, @Attach=@File

Cheers,


~Dave

Thank you! So I take it that it can be done?

I'm really green at this SQL stuff...definitely not a SQL genius as you other guys/gals are. Would someone be willing to give me all of the steps to do this (or point me in the right direction if possible)? I'm even willing to pay if necessary. I found software that does this but it's $500 PER LICENSE and I'm pretty confident there is a native SQL solution.
Go to Top of Page
   

- Advertisement -