Hi,
I was wondering if anyone has extended the standard CDOSYS Mail Stored Procedure (SP) to allow it to send the results of a query as an attachment?
I have set up a SP for CDOSYS Mail as outlined in the following link:
http://support.microsoft.com/default.aspx?id=kb;de;312839&sd=tech
Currently I am using the old SQL Mail (xp_SendMail). But due to the problems with losing the MAPI connection and other limitations, I have been forced to find another solution. Using SQL Mail, I was able to add a query parameter and attach the results of the query to the email. I need to have the same functionality in CDOSYS Mail
Thanks,
KimHi,
I was wondering if anyone has extended the standard CDOSYS Mail Stored Procedure (SP) to allow it to send the results of a query as an attachment?
I have set up a SP for CDOSYS Mail as outlined in the following link:
http://support.microsoft.com/default.aspx?id=kb;de;312839&sd=tech
Currently I am using the old SQL Mail (xp_SendMail). But due to the problems with losing the MAPI connection and other limitations, I have been forced to find another solution. Using SQL Mail, I was able to add a query parameter and attach the results of the query to the email. I need to have the same functionality in CDOSYS Mail
Thanks,
Kim
Jasper has written an sp for it check it out here:
http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=20649|||Sorry, I don't think I explained myself very well!
I currently use xp_sendmail and pass a query as a parameter and attach the results of this query to an email. I would like to know if anyone has extended CDOSYS Mail to have the same functionality? Example of how I use this is in xp_sendmail @.query parameter would be a query which returns the total number of records on an import table and xp_sendmail sends the results in an email attachement OR sends the results as part of the body of the email.
Extract of the xp_sendmail Syntax:
xp_sendmail {[@.recipients =] 'recipients [;...n]'}
[,[@.query =] 'query']
[,[@.attach_results =] 'attach_value']|||I had the same problem and found a workaround using osql to write the results of the query to a file. I then include the file as an attachment and delete it from the server. Seems to work well even within a loop.
I used this to work from.
http://www.sqlteam.com/item.asp?ItemID=4722
And came up with this command line that seems to create a file with the same format as the attach query results did with sendMail:
SET @.bcpCommand = "osql -h-1 -w800 /U usrId /P pw /d " + @.dbName + " /Q ""myprocname parm1, parm2"" -o "
SET @.bcpCommand = @.bcpCommand + @.FileName
EXEC master..xp_cmdshell @.bcpCommand
Then just pass @.fileName as the attachment to the cdosys mail procedure. I then use xp_cmdshell to delete the file from the server.
Showing posts with label include. Show all posts
Showing posts with label include. Show all posts
Wednesday, March 21, 2012
Extended Stored Procedures
Hi !
Please advise which libs and include files are required
to compile extended stored procedure file for SQL Server 2000
in VC++.
Thanks in advance:From SQL 2000 BOL under "extended stored procedures, creating":
To create an extended stored procedure DLL by using Microsoft Visual C++
Create a new project of type Win32 Dynamic Link Library.
Set the directory for include files and library files to C:\Program
Files\Microsoft SQL Server\80\Tools\DevTools\Include and C:\Program
Files\Microsoft SQL Server\80\Tools\DevTools\Lib, respectively.
On the Tools menu, click Options.
In the Options dialog box, click the Directories tab and set the directory
for include files and library files.
On the Project menu, click Settings.
In the Project Settings dialog box, click the Link tab. Click the General
category, and then add opends60.lib to object/library modules.
Add source files (.c, .cpp, and .rc files, and so on) to your project.
Compile and link your project.
Regards
Mike
"IMRAN SAROIA" wrote:
> Hi !
> Please advise which libs and include files are required
> to compile extended stored procedure file for SQL Server 2000
> in VC++.
> Thanks in advance:
>
>
Please advise which libs and include files are required
to compile extended stored procedure file for SQL Server 2000
in VC++.
Thanks in advance:From SQL 2000 BOL under "extended stored procedures, creating":
To create an extended stored procedure DLL by using Microsoft Visual C++
Create a new project of type Win32 Dynamic Link Library.
Set the directory for include files and library files to C:\Program
Files\Microsoft SQL Server\80\Tools\DevTools\Include and C:\Program
Files\Microsoft SQL Server\80\Tools\DevTools\Lib, respectively.
On the Tools menu, click Options.
In the Options dialog box, click the Directories tab and set the directory
for include files and library files.
On the Project menu, click Settings.
In the Project Settings dialog box, click the Link tab. Click the General
category, and then add opends60.lib to object/library modules.
Add source files (.c, .cpp, and .rc files, and so on) to your project.
Compile and link your project.
Regards
Mike
"IMRAN SAROIA" wrote:
> Hi !
> Please advise which libs and include files are required
> to compile extended stored procedure file for SQL Server 2000
> in VC++.
> Thanks in advance:
>
>
Friday, March 9, 2012
Expression to Parameter
I would like my header text not to be hard coded
I took a very big table which include texts i need from my DB to DS
How can i pick a single row with single data in it to be bind
to my Paramter ?
Could you explain this in more detail ?
HTH, jens Suessmeyer.
http://www.sqlserver2005.de
Subscribe to:
Posts (Atom)