Tuesday, September 30, 2014

sharepoint deploy operation is not valid due to the current state of the object

I was getting this error while deploying solution when I added an event receiver for ItemAdded event for document libraries. It disappears after removing the elements.xml file from event receiver schema.

Email handler SPEmailEventReceiver does not work in multiple server farm setup

I came across this situation after developing an email event receiver on dev with standalone sharepoint 2010 installation which was working perfectly fine, but for some reason it was not being fired at all when deployed to the live server with multiple server sharepoint farm. All other things were absolutely fine with the live server and the document library would receive email using OOTB email receiving settings.

After searching a lot through intenet and scraching my head, I came across this post which explains the reason and solution. Thank you Benjamin

http://blog.creative-sharepoint.com/2012/01/sharepoint-2010-email-event-reciever-not-working-in-a-farm/

On another note, a web.config modification also needs to be deployed in a different way on multiple server farm setup. The post below explains just that

http://blogs.msdn.com/b/malag/archive/2009/05/22/spwebconfigmodification-does-not-work-on-farms-with-multiple-wfes.aspx

Wednesday, September 24, 2014

Xpath if else statement

Now this is something... I would like to never recall again :)

I came across a situation where I had to use if..else like statement in Infopath XPath expression and below post solved that problem beautifully..

http://stackoverflow.com/questions/971067/is-there-an-if-then-else-statement-in-xpath


Some more magic in X Path can be seen here

http://incrementaldevelopment.com/xsltrick/


But even after that.. I would prefer to stay away from X Path ;-)

Wednesday, September 17, 2014

Free pdf libraries

Open webpart page in maintenance view

To open a webpart page in maintenance view follow these steps:


  1. Open the document or assets library that contains the page.
  2. Click the Documents or Files tab, select the page, and then in the Manage group, click Edit Properties.
  3. Click Open Web Part Page in maintenance view to display the Web Part Maintenance Page.
Alternatively add ?contents=1 after the page name in url bar

Email mime reader

Codeplex has great utility to read and parse mime email messages

http://mimeparser.codeplex.com/

Tuesday, September 16, 2014

Specified value is not supported for the urlOfFile parameter

This error is misleading, actually we should not use SPFolder.Files collection to retrieve SPFile object the correct way is to use SPWeb.GetFile method.

Reference:
http://www.sharepointnadeem.com/2012/01/urloffile-parameter-name-specified.html

Thursday, September 11, 2014

Rename sharepoint server

Renaming a sharepiont server can get you in serious trouble unless you follow very careful approach. This blog has very useful information which has helped our team resolve the issue that central admin site was unavailable after renaming SP 2010 server

http://blog.walisystemsinc.com/2012/08/how-to-change-sharepoint-2010-server.html

Run miisactivate.exe

This post explains how to fix this error in sharepoint 2010 environment

http://blog.helloitsliam.com/Lists/Posts/Post.aspx?ID=7

Wednesday, September 10, 2014

Email with Embedded (Inline) image in sharepoint

In asp.net we can send an email with inline image as explained in this post
http://stackoverflow.com/questions/18358534/send-inline-image-in-email

But in sharepoint the procedure is slightly different. I have used below post to do the stuff

http://sharepoint-tamizha.blogspot.co.uk/2013/08/send-email-with-embedded-images-in-c.html


And the final code looks like


byte[] imgByte = null;
SPFile file = SPContext.Current.Web.GetFile(ImageUrl);
                                            imgByte = file.OpenBinary();

// Creating Unique ID for adding image referrence
string GUId1 = Guid.NewGuid().ToString();               

// frame the HTML with the img tag and above unique id
string htmlBody = "<html><body><div><img src=\"cid:" + GUId1 + "\"></div></body></html>";

// Create alternateview object with Mime type HTML
AlternateView avHtml = AlternateView.CreateAlternateViewFromString
                    (htmlBody, nullMediaTypeNames.Text.Html);

//Create object for Linked Resource with the Image physical path or Image Stream
MemoryStream stream = new MemoryStream(imgByte);
                LinkedResource pic1 = new LinkedResource(stream, "image/png");

// Provide the previously created Unique ID to associate the Image with the respective img src.
pic1.ContentId = GUId1;

//Add the Linked Resource to the AlternateView
avHtml.LinkedResources.Add(pic1);

string from = SPContext.Current.Web.Site.WebApplication.OutboundMailSenderAddress;

string smtpAddress =SPContext.Current.Web.Site.WebApplication.OutboundMailServiceInstance.Server.Address;

// Assign SMTP address
SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = smtpAddress;

MailMessage mailMessage = new MailMessage(from, toRecipients);
mailMessage.Subject = subject;

// Add the Alternate view with the Mail message
mailMessage.AlternateViews.Add(avHtml);
mailMessage.IsBodyHtml = true;


smtpClient.Send(mailMessage);

Monday, September 8, 2014

Scheduled reminders in Sharepoint 2007

While surfing through google search results I found this great utility created by Mullivan for sp 2007,

http://www.codeproject.com/Articles/32753/Send-scheduled-Reminder-Alerts-by-email-in-SharePo

I can be easily modified to work for SP 2010 and it has a lot of features.


SSL Error - The connection for this site is not secure

 After cloning a git repo of dot net framework website and trying to run it all I could see was this error Turns out the fix was to simply e...