Posterous theme by Cory Watilo

SharePoint 2007 Email SPUtility.SendMail() Guide

This is just a note that I have for using the email server specified in the SharePoint central admin.

StringDictionary headers = new StringDictionary();
headers.add("to","admin@test.com");
headers.add("cc","manager@test.com");
headers.add("bcc","user@test.com");
headers.add("from","myAddress@test.com");
headers.add("subject","How to use SendEMail from SPUtility");
headers.add("content-type","text/html"); //This is the default type, so isn't neccessary.

string bodyText ="This is the body of my email, in html format.“;

SPUtility.SendEmail(web, headers, bodyText);

MSDN Links :-

Windows PowerShell Tutorials

I have a confession to make, a good one. I have always written full blown C# console applications when I want to do some batch jobs that can not be done with STSADM.

I have resisted the idea of going to learn PowerShell for a variety of reasons. However I think it is time for me to stop being an idiot and learn it.

I am currently learning it from this video series:

http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx

Hope this makes my life much easier.

Reading Values From The SharePoint People Editor Field

I had a task that required me to read some values off a SharePoint PeopleEditor control. For the uninitiated, it is a AJAX control that allows you to add users to a field that is verified by LDAP/Active Directory/<insert authentication scheme here>. Screenshot of the control can be seen below:

2011-07-08_18h30_46

Anyway, reading values from it was not exactly a straightforward exercise. After some reading, these were the codes I wrote to read values from that field:

2011-07-08_18h46_39

This works regardless if the PeopleEditor field is set to only use one user or multiple user. 

The alternative method would be to use the ResolvedEntities property which although a working method, is not my preferred method. The reason being that in order to get the SPUser objects, I will have to do the following steps:

2011-07-08_18h56_02

This works great if you only plan to use users that are already registered in the SharePoint site collection. This will fail if the resolved identity is not in the user list (SharePoint Groups and SharePoint All Users) as is you noticed in the code I wrote above, it relies on the SiteUsers property of the RootWeb.

Depending on how you want this to work, both paths provide a way to read values. I would go with the former if it is an open system and the latter if you want it locked down. 

Hope this is of help =)

Why is JSON so popular? Developers want out of the syntax business. | MongoLab

Why is JSON so popular? Developers want out of the syntax business.

There is a reason why JSON is becoming very popular as a data exchange format (more important than it being less verbose than XML): programmers are sick of writing parsers! But “wait”, you say – “surely there are XML parsers available for you to use so that you don’t have to roll your own…”. Yes, there are. But while XML parsers handle the low-level syntactic parsing of XML tags, attributes, etc…, you still need to walk the DOM tree or, worse, build one yourself with nothing but a SAX parser (Objective-C iPhone SDK I’m looking at you!). And that code you write will of course depend on whether the XML you need to make sense of looks like this:

1
<person first-name="John" last-name="Smith"/>

or this:

1
2
3
4
<person>
   <first-name>John</first-name>
   <last-name>Smith</last-name>
</person>

or this:

1
2
3
4
<object type="Person">
   <property name="first-name">John</property>
   <property name="last-name">Smith</property>
</object>

or any of the myriad of other ways one can conceive of expressing the same concept (and there are many). The standard XML parser does not help you in this regard. You still need to do some work with the parse tree.

Working with JSON is a different, and superior, experience. Firstly, the simpler syntax helps you avoid the need to decide between many different ways of representing your data (as we saw above with XML) – much less rope to hang yourself with. Usually there is only one straightforward way to represent something:

1
2
{ "first-name" : "John",
 "last-name" : "Smith" }

Even more important, if you are working in Javascript (which is very often the case when working with JSON), all you need to do is call eval on a JSON string to obtain a first-class Javascript object. This is huge. The subtle point here is that the output of an XML parser is a parse tree, not an object native to the programming language being used. With XML you are still dealing with syntax to a large degree. When you work with JSON you can go straight from a string representation to object (and back).

What makes this possible is that Javascript has syntactic constructs for describing composite data types literally. While virtually all languages have syntax for the literal description of objects of primitive types (integers (e.g. 5), strings (e.g. “hello world”)), not all languages have syntax for the literal description of objects of composite types. For instance, if you want to create a map in Java you need to do it procedurally:

1
2
3
4
5
6
7
Map m = new HashMap();
m.put("a", 1);
m.put("b", 2);
m.put("c", 3);
.
.
.

Java does not have literal syntax for maps. But languages such as Python and Javascript (and others) do. In Javascript we can define our map literally:

1
{ "a" : 1, "b" : 2, "c" : 3, ... }

As it turns out, such sub-languages are a great match for data interchange formats that are both human and machine readable.

As for XML… it’s just not the best for structured data interchange (even with some of the cool Object/XML mapping technologies out there). It works well for markup (i.e. HTML) of text but not as a language for structured data. For that developers want something they don’t have to parse all the time.

Solution to Custom SharePoint 3 List Forms Attachments Feature Not Working - Benjamin Wong's Posterous

As we all know, Windows SharePoint Services 3 has some cool features and allows us to make intranet applications quickly. However as with most software like this, it has some quirks that at times can be very maddening. One of which would be the Attachments feature in SharePoint lists. As I found out during development, I discovered that when you were to customized a listfrom be it edit, add or display, it WILL break the attachments feature in those forms. The words that come out for me were :

This form was customized not working with attachment.

The issue stems from the fact that when we create a customized from using SharePoint Designer 2007, we leave the auto-generated web part in the form but leave it hidden. That is what makes SharePoint think that we did not configure it to accept attachments. Microsoft's support team did come out with patches and a work around this and can be found here.

Much to my annoyance, the fix did not work. While the upload button now works and allows you upload files and it even displays in the forms, it will give you this error :

“Failed to get value of the “Attachments” column from the “Attachments” field type control. See details in log. Exception message: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)”

After some skull cracking and experimentation, it turns out the list form attachments field in the hidden web part and the customized problem was the source of all the issues. Changing this:

ListForm

to

ListForm2
 

After doing that, my form's upload function worked flawlessly.

Hope this article helps somebody so they don't have to bust their brains figuring this one out.

UPDATE

Apparently somebody else also had this issue and solved it the way I had. If only I discovered his article earlier :s

Anyway here is his blog entry : Custom listview with attachments - Jeffrey's Blog

He also mentioned something about the first item not being able to attach files and come up with a solution there.

Sources :

Error message when you try to attach a file in a custom form on the Web site in Windows SharePoint Services 3.0: “This form was customized not working with attachment

Re-posting of an old blog post I wrote to my technical blog.

Mainframe Goodness

Mainframe

As with all coders, I had this itch to relive the old days of computing and what better way to do so than from my mail client. I found this retro look very interesting if not albeit, a tad painful to the eyes. It is not groundbreaking new but cool no less. Now where do I get that  Tron light cycle. 

SGI introduces monster Windows Server for datacenters | ZDNet

“It slices, dices, chops, and peels!”

Well not really, but the SGI Altix UV 1000, fully configured and freshly certified by Microsoft, can be partitioned to hold multiple physical instances of Windows Server 2008 R2 Datacenter Edition, each instance of which can run multiple VMs on Microsoft Hypervisor, making the Altix UV 1000 a potential Windows Azure Cloud in a box solution.

The box itself is capable of supporting up to a maximum of 2048 cores and 16 TB of main memory; Windows Server Datacenter Edition is only capable of supporting up to 1 TB of memory and 128 cores, hence the need to use hardware partitioning to get the most out of the box. A report in The Register quoted Sunny Sundstrom, director of product marketing at SGI, as saying that SGI and Microsoft are working on a certification of the Microsoft OS that will be able to span 256 cores and 2TB of memory.

Given the trend with in-memory database servers, that could be a significant hardware advantage for SGI, when compared with other Windows Server implementations. It should be noted that this certification from Microsoft means it’s a standard version of Windows Server 2008 TR2; there are no special changes or tweaks for Windows Server applications to run in this configuration. So customers who find that they are hardware bound in their current server implementations will have the opportunity to move to a much more capable platform, without the need to touch any custom .NET coding or any of their existing applications already running on Windows Server 2008 R2.

It’s interesting to see the impact of the cloud on this type of technology.  There was a time when an announcement for a “supercomputer” class system would have been accompanied by a host of benchmark results with the crowning glory being something certified by the Transaction Processing Performance Council benchmark.  SGI states that benchmark data with Windows Server and SQL Server will be forthcoming, but the mindset for this type of hardware is now much more forward focused, with the cachet of cloud computing being more of a hook for the attention of potential purchases.

Kick off your day with ZDNet's daily e-mail newsletter. It's the freshest tech news and opinion, served hot. Get it.