Using Twitter’s Web Intents, you can create links like below:
&text=Checkout this awesome blog.&via=chrisbitting&hashtags=twitter"
Which looks like: Tweet
Be sure to check the documentation for more options and details: https://dev.twitter.com/docs/intents
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
//Send the email message and save a copy
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#)
Sometimes it’s handy to grab either a username or email address (why not both?) from active directory. Below are the steps I believe you’ll need to get going quickly. In my example, I’m using VS2012 and .net 4.5.
1. Set your app to use windows authentication, you’ll need to set these to debug in VS:
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Windows" />
<identity impersonate="true" />
<allow users="*" />
<validation validateIntegratedModeConfiguration="false" />
Your project settings:
2. Now in your application, add a reference to System.DirectoryServices:
3. And in your code file:
4. A little function to search through active directory:
private string uEmail(string uid)
DirectorySearcher dirSearcher = new DirectorySearcher();
DirectoryEntry entry = new DirectoryEntry(dirSearcher.SearchRoot.Path);
dirSearcher.Filter = "(&(objectClass=user)(objectcategory=person)(mail=" + uid + "*))";
SearchResult srEmail = dirSearcher.FindOne();
string propName = "mail";
ResultPropertyValueCollection valColl = srEmail.Properties[propName];
5. And finally, how you can use:
string uName = "";
uName = uEmail(HttpContext.Current.User.Identity.Name.Replace(@"yourdomain\", ""));
Hope you enjoy! You can also use this method to retrieve other AD details (groups, full name, etc.).
If you’ve ever used .net to send email messages (and I hope you have!) you may have wanted to send the message from or to not only an address, but also include a name. The ‘display name’ is the name that appears in many email clients instead of the address (think ‘Chris Bitting’ instead of ‘firstname.lastname@example.org’). .Net honors the email standard of “Display Name <email@example.com>”.
Below is a quick example on how this looks in vb.net:
Dim mail As New System.Net.Mail.MailMessage("""Some Body"" <firstname.lastname@example.org>", """A Different Person"" <email@example.com>", "Subject", "Body")
Below is a full example on an email function (include Imports System.Net.Mail): Continue reading “.net SMTP – Sending An Email Message With A Display Name”
If you haven’t already had the need, I’m sure you will at some point, to either retrieve email or send email through Exchange (not just relay or connect to Outlook) using .net. Since Microsoft introduced the Microsoft Exchange Web Services Managed API 2.0 this task has become much more efficient No more clunky 2.0 type web service references etc. Below is a complete chuck of code with a few samples. One sample function sends an email, the other retrieves email messages from an inbox with the option of filters.
Continue reading “Retrieving and Sending Email using Exchange Web Services Managed API 2.0 (c#)”