Click here to Skip to main content
15,884,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I have to write a store procedure which sends an email automatically to the clients.

Actually I need to send an email using store procedure to a specific email id using SMTP.
Can please anybody help me out regarding this query??
Can any body provide me the store procedure?
Posted
Updated 14-Feb-13 21:56pm
v2
Comments
Nelek 15-Feb-13 3:38am    
Nice, good luck.

What have you tried?[^]

Since there is no question at all...

1 solution

Dear,

Try to build an C# CLR method , and call it from SQL , Sample :

C#
public partial class UserDefinedFunctions
{
    [Microsoft.SqlServer.Server.SqlFunction]
    public static SqlString GeregorianDate(SqlString s)
    {
        string hijriDate = s.ToString(); 
        return HijriToGreg(hijriDate);
    }
    public static string HijriToGreg(string hijri)
    {   
            DateTime tempDate = DateTime.ParseExact(hijri,"yyyy-MM-dd",
               new System.Globalization.CultureInfo("ar-SA"));
            return tempDate.ToString("yyyy/MM/dd", new System.Globalization.CultureInfo("en-US").DateTimeFormat); 
    }
};


Deploy the code and then go to he sql managment studio under ypour database--> select programiltry-> select assembly --> right click new assemply and referee to your deployed dll

then you have to enable CLR in SQL :
SQL
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO


then create scaler function with your parameters

SQL
/****** Object:  UserDefinedFunction [dbo].[GeregorianDate]    Script Date: 02/16/2013 10:48:52 ******/
ALTER FUNCTION [dbo].[GeregorianDate](@date [nvarchar](max))
RETURNS [nvarchar](max) WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [GeregorianDate].[UserDefinedFunctions].[GeregorianDate]


then you have to call this function like :

SQL
select [dbo].[GeregorianDate]('01/01/1433')


regards

Abraheem Abulubbad
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900