1 October 2012

Cursor In Sql


declare @dist_code varchar(500)
declare @email varchar(500)

declare crtopic cursor For
SELECT    distinct distributor_master.dist_code, distributor_master.email
FROM  distributor_master INNER JOIN Life_Cycle_Maintain
ON distributor_master.dist_code = Life_Cycle_Maintain.Dist_Code

Open crtopic
Fetch Next From crtopic Into
@dist_code,@email
If @@FETCH_STATUS =0
Begin
while @@FETCH_STATUS = 0
Begin
declare @outputfile varchar(max)
set @outputfile ='E:\Satish\'+ @dist_code +'_'+ REPLACE(getdate(), ':', '_') +'.xls'
declare @query varchar(max)
set @query ='select * from [DTDC_DB].[relapp].[dbo].VW_Dist_sendmail_Data where [Distributor Code]='''+ @dist_code +''' order by [Uniq ID No]'
--print @query
EXEC master.dbo.sp_makewebtask
@outputfile,
@query,
@colheaders =1,
@FixedFont=0,@lastupdated=0,@resultstitle='Caf status details'

Fetch Next From crtopic Into @dist_code,@email
End
End
close crtopic
deallocate crtopic

26 September 2012

Asp.net Book from Dummies

28 August 2012

Send Email With Template


SmtpClient smtp = new SmtpClient(pSMTP);
                 
                    smtp.Credentials = new NetworkCredential(SendEmail, pPass);
                 
                    //Create the MailMessage object
                    MailMessage msg = new MailMessage();

                    //Assign from address
                    msg.From = new System.Net.Mail.MailAddress(pFromEmail);

                    //Assign to address
                    msg.To.Add(new System.Net.Mail.MailAddress(pTo));
                    if (pCc.Trim() != "")
                    {
                        msg.CC.Add(new System.Net.Mail.MailAddress(pCc));
                    }
                    //smtp.EnableSsl = true;
                    //assign subject, and body
                    msg.Subject = pSubject;
                    msg.Body = pBody;
                    msg.IsBodyHtml = Convert.ToBoolean(pFormat);
                    if (pAttachmentPath.Trim() != "")
                    {
                        msg.Attachments.Add(new System.Net.Mail.Attachment(pAttachmentPath));
                    }
                    //Send the message with SmtpClient
                    smtp.Host = "localhost";
                    smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
                    smtp.Send(msg);
                    return true;