Skip to main content

Posts

Ruby : Send email with excel attachment using net/smpt

require 'net/smtp' require 'open-uri' def send_email_with_attachment(subject, body, to_email)  user = ' mailsender@gmail.com '  pwd = 'Mail123Pa55word'  to = to_email  from = ' noreply@baliw.com '  subject = "#{subject}" filename = "Excel_Attachment.xlsx" filename = "xlsTemplate.xls" filename = "xlsxTemplate.xlsx" # Read a file and encode it into base64 format filecontent = File.binread(filename) encodedcontent = [filecontent].pack("m")   # base64 marker = "AUNIQUEMARKER" body = <<EOF This is a test email to send an attachement using net/smpt. EOF # Define the main headers. part1 = <<EOF From: No Reply <#{from}> To: A Test User <#{to}> Subject: Sending Excel Attachement test123 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary = #{marker} --#{marker} EOF # Define the message action part2 = <<EOF Content-Type: text/plain Content-Transfer-Encoding:8bit...

T SQL : SMS Validation format

DECLARE  @BDay varchar(15),  @Code varchar(10),  @CusTomerNo varchar(10) DECLARE  @SMS varchar(500)  ,@OutBoundSMS varchar(500)  ,@WordCount int  ,@IsValidSMS bit --SET @SMS = 'FW 01928 12311995' -- valid --SET @SMS = 'FW 101928 12311995' -- valid --SET @SMS = 'QUERY 101928 12311995' -- Invalid --SET @SMS = 'FW 1x1928 12311995' -- Invalid --SET @SMS = 'FW 1x1928 12.31.1995' -- Invalid --SET @SMS = 'FW 1x1928 12.31.1995' -- Invalid SET @SMS = 'FW' -- Invalid --SET @SMS = 'FW 01928' -- Invalid --SET @SMS = 'FW A1928' -- Invalid SET @IsValidSMS = 0 SELECT  IDENTITY(int, 1, 1) AS Id,  splitdata INTO #temp1  FROM dbo.fnSplitString(@SMS,' ') SELECT @WordCount = COUNT(*) FROM #temp1 IF @WordCount = 3 BEGIN  --SELECT 'Valid 3 words format...'  SELECT TOP 1 @Code = splitdata FROM #temp1 WHERE Id = 1  SELECT TOP 1 @CusTomerNo = splitdata FROM #temp1 WHERE Id = 2    SELECT TOP 1 @BDay = splitdata FROM #temp1 W...

EPPlus : Reading Excel's dynamic worksheets, dynamic rows and dynamic columns

private static void POC_ReadExcelWorksheetsRowsAndColumns() {     string excelFile = @"C:\Raw Excel.xlsx";     using (ExcelPackage package = new ExcelPackage(new FileInfo(excelFile)))     {         foreach (ExcelWorksheet workSheet in package.Workbook.Worksheets)         {             // Make sure its not a blank sheet:             if (workSheet.Dimension == null) continue;             // Get dynamic row and column count:             int rowCount = workSheet.Dimension.End.Row;             int columnCount = workSheet.Dimension.End.Column;             Console.WriteLine("Worksheet name: {0}, with {1} rows and {2} columns", workSheet.Name, rowCount, columnCount);             Console.WriteLine("workSheet.Dimension.Rows: {0}", workSheet.Dimension.Rows);             Console.WriteLine("workSheet.Dimension.Columns: {0}", workSheet.Dimension.Columns);             Console.WriteLine(string.Format("Cell A1 value is {0}", workSheet.Cells["A1...

Heroku push problem : error: src refspec maste does not match any.

> Problem: When issuing command; $ git push heroku maste error: src refspec maste does not match any. error: failed to push some refs to ' https://git.heroku.com/myapp-job.git ' > Resolution: $ git push heroku HEAD:master > Terminal: $ git push heroku maste error: src refspec maste does not match any. error: failed to push some refs to ' https://git.heroku.com/myapp-job.git ' $ git show-ref 830920a24c2c3edbccf9b132a976bf8c72463dc0 refs/heads/master $ git remote -v heroku    https://git.heroku.com/myapp-job.git (fetch) heroku    https://git.heroku.com/myapp-job.git (push) $ git push heroku HEAD:master Counting objects: 11, done. Delta compression using up to 2 threads. Compressing objects: 100% (11/11), done. Writing objects: 100% (11/11), 6.90 KiB | 0 bytes/s, done. Total 11 (delta 0), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Ruby app detected remote: -----> Compiling Ruby/Rack remote: ...