SmtpClient smtpclient = new SmtpClient();
smtpclient.Host = "smtp.gmail.com";
smtpclient.Port = 587;
MailMessage mail = new MailMessage();
mail.IsBodyHtml = true;
mail.Body = "Your email body ";
mail.From = new MailAddress("your email address");
mail.To.Add("To email address");
mail.Subject = "Subject";
smtpclient.EnableSsl = true;
smtpclient.Credentials = new NetworkCredential("youremailID@gmail.com","password");
smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpclient.Send(mail);

Programming is fun and interesting. As you all know, sometime we programmers stucks in the middle way of coding without getting a solution. Blogs like this will help us to find a path to solve our problems. The contents of this blog are the solutions that I found by myself and from other sources. Sharing such solutions is also interesting. Thank you!
Wednesday, December 25, 2013
Send mail using gmail
Sunday, August 18, 2013
Modal Popup - Ajax toolkit
<ajaxToolkit:ModalPopupExtender ID="MPE" runat="server"
TargetControlID="LinkButton1"
PopupControlID="Panel1"
BackgroundCssClass="modalBackground"
DropShadow="true"
OkControlID="OkButton"
OnOkScript="onOk()"
CancelControlID="CancelButton"
PopupDragHandleControlID="Panel3" />
Generate unique key using c#
private string GetUniqueKey()
{
int maxSize = 8 ;
int minSize = 5 ;
char[] chars = new char[62];
string a;
a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
chars = a.ToCharArray();
int size = maxSize ;
byte[] data = new byte[1];
RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
crypto.GetNonZeroBytes(data) ;
size = maxSize ;
data = new byte[size];
crypto.GetNonZeroBytes(data);
StringBuilder result = new StringBuilder(size) ;
foreach(byte b in data )
{ result.Append(chars1)>); }
return result.ToString();
}
{
int maxSize = 8 ;
int minSize = 5 ;
char[] chars = new char[62];
string a;
a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
chars = a.ToCharArray();
int size = maxSize ;
byte[] data = new byte[1];
RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
crypto.GetNonZeroBytes(data) ;
size = maxSize ;
data = new byte[size];
crypto.GetNonZeroBytes(data);
StringBuilder result = new StringBuilder(size) ;
foreach(byte b in data )
{ result.Append(chars1)>); }
return result.ToString();
}
Function for autocompletion
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
ServiceMethod="GetCompletionList" ServicePath="" TargetControlID="TextBox1"
EnableCaching="true" CompletionInterval="1000" CompletionSetCount="12"
MinimumPrefixLength="1">
</cc1:AutoCompleteExtender>
#region AutoComplete
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
//[System.Web.Script.Services.ScriptService]
public static string[] GetCompletionList(string prefixText, int count)
{
ClsBusinessLogicSocialNetwork objQryEx = new ClsBusinessLogicSocialNetwork();
ArrayList arNull = new ArrayList();
if (count == 1)
{
count = 10;
}
DataTable dt = objQryEx.SelectData("tbl_profile", "profile_name","profile_name like '"+prefixText +"%'");
string[] items = new string[dt.Rows.Count];
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string strName = dt.Rows[i]["profile_name"].ToString();
items[i] = strName;
}
return items;
}
else
{
items[0] = prefixText;
return items;
}
}
#endregion
ServiceMethod="GetCompletionList" ServicePath="" TargetControlID="TextBox1"
EnableCaching="true" CompletionInterval="1000" CompletionSetCount="12"
MinimumPrefixLength="1">
</cc1:AutoCompleteExtender>
#region AutoComplete
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
//[System.Web.Script.Services.ScriptService]
public static string[] GetCompletionList(string prefixText, int count)
{
ClsBusinessLogicSocialNetwork objQryEx = new ClsBusinessLogicSocialNetwork();
ArrayList arNull = new ArrayList();
if (count == 1)
{
count = 10;
}
DataTable dt = objQryEx.SelectData("tbl_profile", "profile_name","profile_name like '"+prefixText +"%'");
string[] items = new string[dt.Rows.Count];
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string strName = dt.Rows[i]["profile_name"].ToString();
items[i] = strName;
}
return items;
}
else
{
items[0] = prefixText;
return items;
}
}
#endregion
Subscribe to:
Posts (Atom)