Geeks With Blogs
Mayank Sharma C#
Send Multiple InMemory Attachments Using FileUpload Controls
I wanted to give users an ability to send multiple attachments from the web application. I did not want anything fancy, just a few FileUpload controls on the page and then send the email. So I dropped five FileUpload controls on the web page and created a function to send email with multiple attachments. Here’s the code: public static void SendMail(string fromAddress, string toAddress, string subject, string body, HttpFileCollection fileCollection) { // CREATE THE MailMessage OBJECT MailMessage mail ......

Posted On Wednesday, February 9, 2011 10:16 AM

Automated password expiration notice for Active Directory users
When passwords are set to expire after a certain number of days in Active Directory, the remote users suffer because they do not get a notification like the local users do that their password is going to expire. Eventually, it becomes too late for them to change their passwords and they get locked out. I found this out recently and did not believe that there was no built in support for this. I started researching and indeed, there was no built in support. The solution was to email the users, either ......

Posted On Friday, October 30, 2009 8:44 AM

Return SqlDataReader from a method
.NET's SqlDataReader class is based on an active connection to the database. This means that while the SqlDataReader is in use, the SqlConnection that is serving the SqlDataReader is open and cannot be used anywhere else. That is why, returning an SqlDataReader from a method is not stright forward like returning a DataTable or a DataSet. To read more about SqlDataReader, please see SqlDataReader class. Though it is not straight forward, it is very simple. Here's a piece of code that would let you ......

Posted On Tuesday, May 26, 2009 1:58 AM

Compress Image files using C#
Found a nice post by Mr.Polite for compressing JPEG images. Here's the link: Posting the code here for my reference in case the original post gets deleted or changed. Image myImage = //... load the image somehow // Save the image with a quality of 50% SaveJpeg (destImagePath, myImage, 50); //add this! using System.Drawing.Imaging; /// <summary> /// Saves an image as a jpeg image, with the given quality /// </summary> /// <param name="path">Path ......

Posted On Wednesday, April 29, 2009 8:15 AM

Hyperlink to Windows Remote Desktop (RDP) session using ASP.NET
Hyperlink to Remote Desktop (RDP) session: I had some IP addresses on a web page which would be used internally by our company users and wanted to display them as hyperlinks. When a user clicks an IP address, a Windows RDP session should start. The simplest way I could think of was to transfer an RDP file to the client, which she can open or save via regular HTTP File Transfer. An RDP file can be edited by a simple text editor. If you open an RDP file with notepad, you will see all the settings. ......

Posted On Tuesday, March 17, 2009 1:54 AM

How to bulk upload images to SQL Server using DotNetZip library
Previously I posted an example on how to download multiple images or files using DotNetZip library here. Today I will explain how we can use the same library to unzip images from a zipped folder and insert them into an SQL Server table. Note: I have used NeatUpload library developed by Dean Brettle to display import progress to the user which can be found here. If you don’t want to use it, remove the namespace from the code and modify the code to not use NeatUpload controls. Libraries used: 1. DotNetZip ......

Posted On Monday, February 2, 2009 4:47 AM

How to get a return value from a Stored Procedure that just returns a value without a parameter
Scenario - My stored procedure just returns some integer values depending on different conditions. There are no OUT or any other parameters involved for returning values from the stored procedure. e.g. IF (EXISTS( SELECT * FROM TableName WHERE UserId = @UserId AND RoleId = @RoleId)) RETURN(1) ELSE RETURN(0) If you notice, there are no output parameters involved here. The return value can be accessed from code (C# for example), like this: SqlParameter returnValueParam = command.Parameters.Add("@re... ......

Posted On Friday, January 2, 2009 8:08 AM

Copyright © bullpit | Powered by: