How to Send E-Mail Via Gmail in C#

0 comments

Well, you can find this kind of information almost every where but I wanted to give a slick and concise information on how to send e-mail in C# using Gmail Servers.

Here is the code, I believe you can understand once you walk thru it :

MailMessage _message = new MailMessage(new MailAddress("email@gmail.com", "Info"), new MailAddress(_email));
                _message.Subject = "Password Recovery";
                _message.Body = "Dear User
This is your password : " + _password + ".

Please keep it secure.

"; _message.IsBodyHtml = true; SendEmail(_message) public void SendEmail(MailMessage message) { EmailConfig _config = new EmailConfig("SystemAccount"); message.From = new MailAddress(_config.UserName, _config.From); message.Body += _config.Signature; SmtpClient client = new SmtpClient(); client.EnableSsl = Convert.ToBoolean(_config.EnableSSL); client.Host = _config.Host; client.Port = _config.Port; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Credentials = new System.Net.NetworkCredential(_config.UserName, _config.Password); client.Send(message); }

"Thread was being aborted" problem ?

0 comments

Recently I've got this error on my Asp.NET application and I found this way by myself to solve it :


public static void WriteJSONObject(this HttpResponse response, object content) 
{
            response.ContentType = "application/json";
            response.Write(new JavaScriptSerializer().Serialize(content));
            response.End();
}

public void RegisterUser() 
{
    try 
    {
       Response.WriteJSONObject(new { Result = "See hello" });
    } 
    catch (Exception err) 
    {
        if (err.Message != "Thread was being aborted.")
            Response.WriteJSONObject(new { Result = err.Message });
        else 
        {
            Response.End();
        }
    }
}

How to Abort jQuery Ajax Requests

0 comments

Hi everyone,

It's been long time since the last time and I decided to post a useful content :  "How to abort and track the status of jQuery Ajax requests."

First we all should know the return types of jQuery ajax methods, so lets walk thru their return types :


jQuery.ajax( options )Returns: XMLHttpRequest
Load a remote page using an HTTP request.
load( url, datacallback )Returns: jQuery
Load HTML from a remote file and inject it into the DOM.
jQuery.get( url, datacallbacktype )Returns: XMLHttpRequest
Load a remote page using an HTTP GET request.
jQuery.getJSON( url, datacallback )Returns: XMLHttpRequest
Load JSON data using an HTTP GET request.
jQuery.getScript( url, callback )Returns: XMLHttpRequest
Loads and executes a JavaScript file using an HTTP GET request.
jQuery.post( url, datacallbacktype )Returns: XMLHttpRequest
Load a remote page using an HTTP POST request.


As long as they return XMLHttpRequest we can use methods peculiar to XMLHttpRequest. You can find the complete reference of XMLHttpRequest here

And this is code how to handle status changes :
function() {
    var _resultText = $("#r_ResultText");

    _loading.show();
    _resultText.hide();

    var _ajaxRequest = $.getJSON("login.aspx?callback=SendPassword");

// this is the code which handles status 
    _ajaxRequest.onreadystatechange = function() {
    if (_ajaxRequest.status == 408) { //time out code
        _loading.hide();
        _resultText.show().html("Result:
" + "Time-Out, please try again in a few minutes");
         }

    }

Visual Studio Intellisense for jQuery Library

0 comments

If you want to use jQuery Intellisense for Visual Studio, Microsoft already provides it. Here is how :
  1. Visual Studio 2008, install hotfix KB958502
  2.  download the vsdoc file to the same folder as the original jQuery.js file and make sure that file names match, i.e. if original file name is jquery-1.3.2.js, then the vsdoc file should be named jquery-1.3.2-vsdoc.js (notice: not vsdoc2.js); if you're using the min version of the file, adjust the name accordingly. 
  3. Third, do not include the vsdoc file in the project (it's enough for the file to be in the same folder). Finally, to enable IntelliSense in custom JavaScript files, add the following line at the top of the JavaScript file (enter the correct path).









P.S : To refresh JavaScript IntelliSense, press Ctrl+Shift+J.

Need Some Rest ?

0 comments

I want to keep this post simple. Do you feel like your brain is not working any more ? Because this is how I am feeling right now. I can't even think about anything. I don't know how I could write this post but umm I think I need some rest w/o my laptop and books. Writing/reading thinking even though I would like to get some vacation after leaving my job but I think my responsibilities are getting higher after leaving my job. That's not fair and white hairs on my head are getting to increase. Every day I see a new white hair and I am 23 years old. What's happening to me ? I am pressing on myself too hard ?

Google and New Google Wave API

0 comments

Google will provide users a new real time communication platform. Developer can now reach the API to write something on their own. The best innovation in this technology is Real Time Communication between clients. Watch what exactly I mean :

Get Your Own Blog for 10 Dollars.

0 comments

Yes, as you read at the title, you can have a blog site for 10 dollars for a year. Pretty nice deal huh ? And you don't need to install anything on anywhere, you don't need to struggle with hosting provider problems or other things. You don't even need to relay domain namespaces to anywhere.




Do what I've done :
  1. Have a blogger blog site.
  2. Buy a custom domain name thru Blogger > Settings > Publishing
  3. Google will charge you 10 dollars for your custom domain and handle everything for you.
  4. Pick up a nice template from BTemplates and edit your html layout and apply new settings to your blog.
And you are not all set.It's also pretty easy to set up your own blog. Even your domain name expires, you can continue with your old domain name Google Blogger provides you. You gain at least 50 dollars per yer for your blog and I think it's a pretty nice deal.

Hope it helps you.