Tweet button / link without javascript – HTML only

Twitter buttonIf you’ve ever wanted to include a ‘Tweet’ button or link but didn’t want to use the popular Tweet Button code from Twitter (it uses a remote javascript function), there is an alternate approved method called “Intents”. This function works great for instances when simple HTML is preferred (emails, pages geared toward older or simple browsers, etc.). However it doesn’t provide extras like showing how many have used the button or creating the image automatically. So how does it work?

Using Twitter’s Web Intents, you can create links like below:

<a href="http://twitter.com/intent/tweet?url=http://chrisbitting.com
&text=Checkout this awesome blog.&via=chrisbitting&hashtags=twitter"
 title="Tweet" target="_blank">Tweet</a>

Which looks like: Tweet

No Javascript!

Be sure to check the documentation for more options and details: https://dev.twitter.com/docs/intents

Tweet button / link without javascript – HTML only

Uploading a file via FTP in .net c#

uploadRemember when uploading a file via ftp was more a pain and took some third party components for stability? Now I have more trust in the .net method, below is a function I use for uploading a file:

You could call this function like:

ftpFile("current.jpg",@"C:\temp\some.jpg");

And the function: Continue reading “Uploading a file via FTP in .net c#”

Uploading a file via FTP in .net c#

Adding attachments to an email using Exchange Web Services

In a previous article on sending email with Exchange Web Services (EWS) we showed how easy it was to integrate with Exchange and send email. If you’ve ever wanted to attach a file to an email that your sending, it’s super easy (much faster than the┬áSystem.Net.Mail method):

//Create an email message and identify the Exchange service
EmailMessage message = new EmailMessage(service);

//Attach a file - THE MAGIC
message.Attachments.AddFileAttachment(@"c:\temp\somefile.jpg");

//Send the email message and save a copy
message.SendAndSaveCopy();

That’s it! If you want to see all of the code needed for sending, see Retrieving and Sending Email using Exchange Web Services Managed API 2.0 (c#)

Adding attachments to an email using Exchange Web Services

Setting a cookie to expire in javascript

cookietimeAdding and setting a cookie via javascript is pretty simple. Sometimes you want the cookie to expire in a certain amount of time, below is the method is use to calculate an expiration:

//create a date object
var date = new Date();
//add the current date + some seconds 
//(below I add 300 seconds or 5 minutes). 
//The 1000 is milliseconds
 date.setTime(date.getTime() + (300 * 1000));
//convert the future date to universal time
var expires = date.toUTCString();
//set the cookie using whatever method / function you choose.
setCookie('cookiename', 'cookievalue', expires);

For the fun of it, below is the function I use to set cookies:

function setCookie(cname, cvalue, expires) {
 document.cookie = cname + "=" + escape(cvalue) +
 ((expires) ? "; expires=" + expires : "");
}

And since we’re talking about cookies, here is a collection of great cookies recipes you can actually eat!

Setting a cookie to expire in javascript