Blog of an overweight SharePoint addict

Thu 29 May 08

Using the undocumented SPUtility.SendEmail method.

Filed under: General, Programming, SharePoint, Visual Studio 2005 — Reginald @ 3:31 pm

As with a lot of the sharePoint API, the SPUtility class and more importantly the sendEMail method lacks a decent amount of documentation on its use.

After a little bit of playing around with a console session, I’ve found what seems to be the best way to use this function. (For me at least.. feel free to disagree!!)

Requires:
using System.Collections.Specialized;

For the purposes of my test code, I used a console sessions and wrapped the send email process inside two using statements to populate site and web with the test sharepoint site.


StringDictionary headers = new StringDictionary();
headers.add("to","reginald@myfatblog.co.uk");
headers.add("cc","thisiscopy@myfatblog.co.uk");
headers.add("bcc","thisistheblindcopy@myfatblog.co.uk");
headers.add("from","MySharePointEmail@myfatblog.co.uk");
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);

The SendEmail method makes it very easy to pop emails out using your SharePoint sites current SMTP configuration, the only downside is that this does not allow you to use attachments. If you need to do this, then you’ll need to look down the .Net mail methods.. (I found a decent post on David Fekkes blog on how to do this using the .Net methods. I haven’t tried it yet, but it’s a good starting point. Email with attachments from SharePoint code.

Thu 8 May 08

Failing to display the InfoPath workflow form.

Filed under: Infopath, SharePoint, Workflow — Reginald @ 4:33 pm

We’ve hit an unusual problem in our estate with the SharePoint implementation. Around a month ago, a number of our users had their machines upgraded to Office 2007. Today when they tried to edit a workflow task assigned to them, the page loaded, but the browser based infopath form failed to display and IE showed the Errr on Page icon in the bottom left hand corner.

When you click on the error and choose show detail, You’ll see, “Line: 1935 Char: 4 Error: Library not registered. Code: 0 URL: http://server/site/page.aspx?list=etc…”

Not the most useful of errors you’ll agree. The resolution is to run Word 2007, click on the Office Button, choose Word options, Resources and then run the Office Diagnostics. Once this has run through, restart IE and it all seems to work!

Reg.

Field Type errors in webparts.

Filed under: Programming, SharePoint, Visual Studio 2005 — Reginald @ 10:29 am

I’ve been making some changes to the Summaries webPart this week following the successful beta with the users. The key problem I hit was an unexpected error when changing one of the selected views in the web part. I received a very helpful

“One or more field types are not installed properly. Go to the list settings page to delete these fields.”

Well this is a very useful error, Resolve the problem by deleting the fields causing the issue? in this instance however, there isn’t actually a problem, The issue is caused by the CAML used to return the data for the webpart. In Dev, it was looking for “Projects_x0020_Task_x0020_Complete” and in Live it should have been “Projects_x0020_Involvement_x0020_Complete”. Simple schoolboy error and easily solved, but not helped by the error message, so one to watch out for in future.

Update: This came about because the column had been renamed long ago, therefore the program I used to extract the column name showed the internal name of Project Tasks Complete, whereas I had renamed it to Projects Involvement Complete before porting the whole lot to live!

Powered by WordPress