26 May 2012

send email using asp classic

If you ever wish to use asp classic and want to send an email through asp classic code, you can use following code to do your job.

Happy coding! ;)

<%
    Option Explicit

    Dim objNewMail

    'create an instance of NewMail Object
    Set objNewMail = Server.CreateObject("CDONTS.NewMail")

    ' After an instance of NewMail Object has been created.
    ' If you like you can use this one line of code to send the mail.
    ' objNewMail.Send From, To, Subject, Message
    ' or you can give every value seperate

    objNewMail.From = "emailfrom@yourdomain.com"
    objNewMail.To   = "emailto@yourdomain.com"

    ' Please replace the "From" and "To" email addresses with your 
    ' own valid email address.

    objNewMail.Subject = "This is a test Mail"
    objNewMail.Body    = "This is the Body text of this test mail."
    objNewMail.Send

    ' After the Send method, NewMail Object become Invalid
    ' You should set it to nothing to relase the memory

    Set objNewMail = Nothing

    ' If you want to send another mail
    ' you have to create a new instance of NewMail Object again.

    Response.Write "Email has been sent"

%>
25 May 2012

twitter guys fed up or what?

I was just spying on what twitter guys do behind the scenes, I found a http request named available features which is made after every few seconds or may be minutes, and tells is current logged in user has permission of available features or not.

It seems that twitter guys are now fed up with twitter and therefore using hanky panky names in API.

Following is response object of available features request in json format. Check it out and make sure you check out the name of last property of response object. :p

{ 
    "activity_dark_read": 1,
    "activity_modal": 1,
    "activity_read": 1,
    "activity_status_summary": 1,
    "advanced_search": 1,
    "api_per_country_takedown": 1,
    "avatar_upload": 1,
    "bananaquit_dnt_scribe": 1,
    "bananaquit_show_opt_out": 1,
    "big_photo_permalink": 1,
    "contact_import": 1,
    "contact_import_stream": 1,
    "conversations": 1,
    "dashboard_activity_followers": 1,
    "dashboard_activity_following": 1,
    "email_device_settings": 1,
    "embed_code_dialog": 1,
    "empty_timeline_recommendations": 1,
    "escape_ampersands_in_search_highlighter": 1,
    "eurl_dwell_time_store": 1,
    "fake_loggedout_decider": 1,
    "flock": 1,
    "geo_allow_set_location_manually": 1,
    "geo_location": 1,
    "geo_more_places": 1,
    "geo_place_creation": 1,
    "geo_show_similar_places": 1,
    "geo_ui": 1,
    "geo_ui_dropdown_available": 1,
    "html5Routing": 1,
    "i18n_new_translation_center": 1,
    "in_reply_to_component": 1,
    "infinite_scroll": 1,
    "inline_media_component": 1,
    "japanese_ad_component": 1,
    "japanese_new_ad_provider": 1,
    "list_stream_memberships": 1,
    "list_stream_own_lists": 1,
    "list_stream_subscriptions": 1,
    "list_streams": 1,
    "local_trends": 1,
    "logged_out_people_search": 1,
    "media_flagging": 1,
    "message_stream": 1,
    "mobile_download_gallery": 1,
    "mobile_download_gallery_logged_out": 1,
    "more_lists_component": 1,
    "mt_tweet_backend_bing": 1,
    "newest_list_members_component": 1,
    "news_onebox": 1,
    "old_webclient_events": 1,
    "onebox": 1,
    "onebox_user_search": 1,
    "people_stream_follower_requests": 1,
    "people_stream_followers": 1,
    "people_stream_fresh": 1,
    "people_stream_friends": 1,
    "people_stream_list_followers": 1,
    "people_stream_list_members": 1,
    "people_stream_people_search": 1,
    "people_streams": 1,
    "personalization_preview": 1,
    "personalization_settings": 1,
    "phoenix_amazon_details": 1,
    "phoenix_aol_video": 1,
    "phoenix_apple_itunes": 1,
    "phoenix_apple_itunes_more": 1,
    "phoenix_autocomplete": 1,
    "phoenix_facebook_details": 1,
    "phoenix_facets": 1,
    "phoenix_facets_images": 1,
    "phoenix_facets_logged_out": 1,
    "phoenix_facets_videos": 1,
    "phoenix_first_time": 1,
    "phoenix_flickr_details": 1,
    "phoenix_instagram_and_friends": 1,
    "phoenix_local_foursquare": 1,
    "phoenix_local_gowalla": 1,
    "phoenix_local_meetup": 1,
    "phoenix_local_plancast": 1,
    "phoenix_pctd": 1,
    "phoenix_preload_twimgs": 1,
    "phoenix_scribe": 1,
    "phoenix_search_dropdown": 1,
    "phoenix_search_relevance": 1,
    "phoenix_search_relevance_logged_out": 1,
    "phoenix_turkey_flash": 1,
    "phoenix_turkey_html5_resize": 1,
    "phoenix_turkey_permalink": 1,
    "phoenix_tweetbox_talon": 1,
    "phoenix_url_resolver": 1,
    "phoenix_user_media_gallery": 1,
    "phoenix_whosay_details": 1,
    "phoenix_wordpress_details": 1,
    "photo_copy_paste_inception": 1,
    "place_people_component": 1,
    "place_tweets_component": 1,
    "place_users_stream": 1,
    "profile_combined_api": 1,
    "profile_image_latency": 1,
    "profile_pane_fresh": 1,
    "profile_tweetbox": 1,
    "promo_component": 1,
    "promoted_accounts_in_whotofollow_viewall": 1,
    "promptbird_phoenix": 1,
    "ptw_reinjection": 1,
    "recent_tweets_component": 1,
    "scribe_client_event": 1,
    "scribe_form_piggyback": 1,
    "scribe_image_failures": 1,
    "search_assistance": 1,
    "social_context": 1,
    "sports_onebox": 1,
    "sports_onebox_polling": 1,
    "ssl_cdn_akamai_fraction": 1,
    "stork_guidance": 1,
    "suggestion_categories_streams": 1,
    "swift_action_queue": 1,
    "swift_discover": 1,
    "swift_impression_cookie": 1,
    "swift_mobile_download_gallery": 1,
    "swift_permalink": 1,
    "t1_dm_poll": 1,
    "t1d_topic_img": 1,
    "t1d_topic_vid": 1,
    "t1d_tweet_img": 1,
    "t1d_tweet_vid": 1,
    "trends_component": 1,
    "trends_component_polling": 1,
    "turkey": 1,
    "tweet_geo_component": 1,
    "tweet_stream_favorites": 1,
    "tweet_stream_favorites_polling": 1,
    "tweet_stream_following": 1,
    "tweet_stream_following_polling": 1,
    "tweet_stream_home": 1,
    "tweet_stream_home_polling": 1,
    "tweet_stream_list": 1,
    "tweet_stream_list_polling": 1,
    "tweet_stream_mentions": 1,
    "tweet_stream_mentions_polling": 1,
    "tweet_stream_profile": 1,
    "tweet_stream_profile_polling": 1,
    "tweet_stream_retweets_by_others": 1,
    "tweet_stream_retweets_by_others_polling": 1,
    "tweet_stream_retweets_by_you": 1,
    "tweet_stream_retweets_by_you_polling": 1,
    "tweet_stream_search": 1,
    "tweet_stream_search_polling": 1,
    "tweet_stream_user": 1,
    "tweet_stream_user_polling": 1,
    "tweet_stream_your_tweets_retweeted": 1,
    "tweet_stream_your_tweets_retweeted_polling": 1,
    "tweet_streams": 1,
    "tweet_streams_polling": 1,
    "typeahead": 1,
    "typeahead_global_nav": 1,
    "typeahead_local_queries": 1,
    "typeahead_saved_searches": 1,
    "use_scribe_post": 1,
    "user_onebox": 1,
    "user_shuffler": 1,
    "welcome_ad_track": 1,
    "welcome_profile": 1,
    "welcome_warm_signup": 1,
    "whotofollow_random_sample": 1,
    "whotofollow_recommendations": 1,
    "whotofollow_similarities": 1,
    "wtf_signup_suggestions": 1
}
23 Feb 2012

What is my ip?

Ah! after spending a lot of time in googling that how can I detect IP address of a user via client side script, I found a website which does nothing, but only tells you the ip address of current user in json format (such a simple work but great!). So I wrote a small javascript to query that site via ajax and get the result in json format.

following is the small snippet of code which does the task ;)

code snippet

// call the json api to get IP address
$.getJSON('http://jsonip.appspot.com/?callback=?', function(result){

    // IP address found, display in alert
    alert('Your public IP address is: ' + result.ip)

});

See a working demo here

12 Dec 2011

Adding attributes on body tag from server-side

today, I ran into an issue that I had to make some interface changes based on different devices like iPhone, iPad, Android etc via CSS.

I thought to apply a css class on the body tag, and then handle the inteface changes in the stylesheet.

since body tag is in the masterpage and can not be accessed directly, therefore I had to do a small trick ;) see the code below.

Markup code

<!-- Assign an id to body tag and add runat="server". -->
<body id="page_body" runat="server">

Server side

/// <summary>
/// Page Load event of current page
/// </summary>
/// <param name="sender" />
/// <param name="e" />
protected void Page_Load(object sender, EventArgs e)
{
    // initialize browser detector class
    BrowserDetector browserDetector = new BrowserDetector();

    // get the operating system name, being used by client
    var os = browserDetector.OS.ToLowerInvariant();

    // get the body tag from masterpage
    HtmlGenericControl body = (HtmlGenericControl)this.Page.Master.FindControl("page_body");

    // if body tag found successfully
    // then apply class attribute on it, so simple :)
    if (body != null)
    {
        body.Attributes.Add("class", "os-" + os);
    }
}
16 Jan 2011

ASP.NET MVC 3 released

For so long, I was waiting for the final release of ASP.NET MVC 3, and now the wait ends and I should properly dive into MVC. ;)

Download and Install ASP.NET MVC 3

Following is the list of some key features and improvments in ASP.NET MVC 3:

There are a lot more great improvements in ASP.NET MVC 3 listed below:

  • Improved New Project dialog that makes it easy to start new ASP.NET MVC 3 projects from templates.
  • Improved Add->View Scaffolding support that enables the generation of even cleaner view templates.
  • New ViewBag property that uses .NET 4’s dynamic support to make it easy to pass late-bound data from Controllers to Views.
  • Global Filters support that allows specifying cross-cutting filter attributes (like [HandleError]) across all Controllers within an app.
  • New [AllowHtml] attribute that allows for more granular request validation when binding form posted data to models.
  • Sessionless controller support that allows fine grained control over whether SessionState is enabled on a Controller.
  • New ActionResult types like HttpNotFoundResult and RedirectPermanent for common HTTP scenarios.
  • New Html.Raw() helper to indicate that output should not be HTML encoded.
  • New Crypto helpers for salting and hashing passwords.
  • And much, much more…

More about ASP.NET MVC 3

read more details on Scott Gu’s blog

Zain Shaikh's Posterous

A 'Workaholic', MCP & MCTS, Web Designer & Developer Working with ASP.Net, Silverlight and WCF, and a Poetry lover as well :)
My Google Profile


I am Microsoft Certified Professional :)
Follow me on twitter

 Subscribe in a reader

If you would like to recieve updates via email, simply enter your email address below & click subscribe.