A straightforward way of sending email from within a SharePoint 2007 application is to use the Object Model. Here is some C# code that will do it for you:
bool isAppendHtmlTag = true;
bool isHtmlEncode = false;
string recipient = "whoever@whatever.com";
string title = "This is the title";
string body = "This is the email <strong>body</strong>";
Microsoft.SharePoint.Utilities.SPUtility.SendEmail(
Microsoft.SharePoint.SPContext.Current.Web,
isAppendHtmlTag,
isHtmlEncode,
recipient,title,
body);
Thursday, July 24, 2008
Sunday, July 20, 2008
Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances.
Recently I noticed that many of my ASP.NET applications that work with a SQL Server Express database that resides in the App_Data directory stopped working. The culprit error was "Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances.". I suspect that a SQL Server update went out that disables user instances. I have not been able to substantiate this suspicion yet.
SOLUTION:
The solution is to enable user instances with the following command:
sp_configure 'user instances enabled','1';
Disable user instances with the following command:
sp_configure 'user instances enabled','0';
SOLUTION:
The solution is to enable user instances with the following command:
sp_configure 'user instances enabled','1';
Disable user instances with the following command:
sp_configure 'user instances enabled','0';
Friday, July 18, 2008
How to change the connection string name in a .NET 3.5 LINQ to SQL class?
Here's the scenario:
You developed an application that uses "LINQ to SQL" with a connection string name (say aa-db). In production you want the name to be different (say bb-db). What do you need to do to change the connection string name?
1) Open the *.dbml file in a text editor.
2) Change the "SettingsPropertyName=" property to the new name
3) Open the "*.designer.cs" file that is associated with the LINQ class and change the value of global::System.Configuration.ConfigurationManager.ConnectionStrings[...].
You developed an application that uses "LINQ to SQL" with a connection string name (say aa-db). In production you want the name to be different (say bb-db). What do you need to do to change the connection string name?
1) Open the *.dbml file in a text editor.
2) Change the "SettingsPropertyName=" property to the new name
3) Open the "*.designer.cs" file that is associated with the LINQ class and change the value of global::System.Configuration.ConfigurationManager.ConnectionStrings[...].
How to edit group on the SharePoint quicklaunch in WSS 3.0 (and MOSS 2007)?
It is always a good idea to lock down SharePoint sites such that users do not see more information than they need to. At the organization where I work, we have a plethora of SharePoint groups. With any new website that gets created, a user with full rights gets to see a list of all the groups by going to "Site Actions / Site Settings / Advanced Permissions". There is always the danger that a user can inadvertently delete or add a user to the wrong group. One simple solution is to remove unneeded groups from the quicklaunch. Here's what you can do:
- Click on Site Actions / Site Settings / Advanced Permissions
- Click on any group on the quicklaunch under "Groups"
- Click on Settings / Edit Group Quick Launch
- On the "Edit Group Quick Launch" page, highlight any group and hit the delete key on your keyboard
Wednesday, July 2, 2008
What is an easy way to find out the internal name of a SharePoint 2007 list column?
The internal name of a SharePoint list column can be different from the display name. This could happen if a column name has been renamed to something else. For example, if you rename the "Title" column to, say, "Company Name", the internal name remains as "Title". Also, spaces in the display name are replaced with "_x0020_" in the internal name. The internal name of "Contract_x0020_Type" would be used for display name "Contract Type".
An easy way to discover the internal name without any programming is:
- add the column to a view
- click on the column name to sort the view by that column
- check the URL for the "SortField=" parameter value.
I did this for a column name "Company Name" and got a URL similar to this:
http://www.domain.com/records/Documents/Forms/AllItems.aspx?SortField=Company%5fx0020%5fName&SortDir=Asc&View=%7b0E0FDBDA%2d1BA5%2d4CE1%2dBEE4%2d191B285E1F8A%7d
The above URL suggests that the internal field for "Compnay Name" is "Company_x0020_Name".
Note that the URL encoding for the underscore is "%5f".
An easy way to discover the internal name without any programming is:
- add the column to a view
- click on the column name to sort the view by that column
- check the URL for the "SortField=" parameter value.
I did this for a column name "Company Name" and got a URL similar to this:
http://www.domain.com/records/Documents/Forms/AllItems.aspx?SortField=Company%5fx0020%5fName&SortDir=Asc&View=%7b0E0FDBDA%2d1BA5%2d4CE1%2dBEE4%2d191B285E1F8A%7d
The above URL suggests that the internal field for "Compnay Name" is "Company_x0020_Name".
Note that the URL encoding for the underscore is "%5f".
Subscribe to:
Posts (Atom)