Click here to Skip to main content
12,074,449 members (59,563 online)
Rate this:
 
Please Sign up or sign in to vote.
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 14-Feb-13 22:11pm
Edited 14-Feb-13 22: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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Dear,

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

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 :
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO

then create scaler function with your parameters

/****** 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 :

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

regards

Abraheem Abulubbad
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160208.1 | Last Updated 16 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100