Saturday, May 15, 2010

Send Mail in C#

using System.Net.Mail;

MailMessage objMessage = new MailMessage();

objMessage.Bcc.Add(dicInputs["Bcc"].ToString().Trim());
objMessage.From = new MailAddress(dicInputs["From"].ToString().Trim());
objMessage.To.Add(dicInputs["To"].ToString().Trim());
objMessage.Subject = dicInputs["Subject"].ToString().Trim();
objMessage.Body = dicInputs["Message"].ToString().Trim();

string[] sAttachments = null;

sAttachments = dicInputs["Attachments"].ToString().Split(',');

for (int intLoop = 0; intLoop <= sAttachments.GetUpperBound(0); intLoop++)
{
strLogOut = strLogOut + "Adding attachment '" + sAttachments[intLoop] + "'";
objMessage.Attachments.Add(new Attachment(sAttachments[intLoop]));
}


SmtpClient objClient = new SmtpClient();
objClient.Host = "";
objClient.Send(objMessage);

Thursday, May 13, 2010

Thursday, May 6, 2010

DateDiff in Months C#

private static long monthDifference(DateTime startDate, DateTime endDate)
{
long monthsApart = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
return Math.Abs(monthsApart);
}

Thursday, April 29, 2010

Arraylist to String c#.net

public string toDelimitedString(string delimiter)
{

if (intAmvrrayItms > 0)
{

string[] srtArray = arrStringArray.ToArray(Type.GetType("System.String")) as string[];

return string.Join(delimiter, srtArray);
}

return null;


}

Monday, April 12, 2010

Precompiling Your Website

Visual Studio offers ASP.NET developers two different project types: Web Application Projects (WAP) and Web Site Projects (WSP). One of the key differences between these project types is that WAPs require explicit compilation whereas WSPs use automatic compilation, by default. With WAPs, you compile the web application's code into a single assembly, which is created in the website's Bin folder. Deployment entails copying the markup content (the .aspx.ascx, and .masterBin folder; the code-behind class files themselves do not need to be deployed. On the other hand, you deploy WSPs by copying both the markup pages and their corresponding code-behind classes to the production environment. The code-behind classes are compiled on demand on the web server. files) in the project, along with the assembly in the Know More

Downloading any file to the browser, ASP.Net

Click Here

Monday, March 1, 2010

Rijndael Encryption

Please see this sample code for Rijndael encryption technique:

http://www.freevbcode.com/ShowCode.Asp?ID=4520