Microsoft KB Archive/936760

= The URLs of alerts in e-mail notifications that you receive are incorrect after the URL of a Web application for a site in Windows SharePoint Services 3.0 or in SharePoint Server 2007 changes =

Article ID: 936760

Article Last Modified on 5/10/2007

-

APPLIES TO


 * Microsoft Windows SharePoint Services 3.0

-



SYMPTOMS
You create one or more alerts for a list or for a document library in a site in Microsoft Windows SharePoint Services 3.0 or in Microsoft Office SharePoint Server 2007. In scenarios in which the URL of the Web application for the site changes, the URLs in the body of the e-mail notifications that you receive are incorrect. The URLs are still the old URL.



CAUSE
This issue occurs because URLs of alerts are stored as absolute URLs in the content database. Therefore, if the URL of the Web application changes, the URL of the alert is still the old URL. For example, this issue occurs if one of the following conditions is true:
 * The host name changed.
 * The port that the Web application uses changed.
 * The name of the server changed.



WORKAROUND
To work around this issue, resave each alert. You do not have to make any changes to the alert before you resave it. To resave an alert, follow these steps:
 * 1) Connect to the home page of the site, click Welcome   at the top of the page, and then click My Settings.
 * 2) Click My Alerts.
 * 3) On the &quot;My Alerts on this Site&quot; page, click an alert.
 * 4) On the Edit Alert page, resave the alert. To do this, click OK. You do not have to make any changes to the alert before you resave it.

This procedure updates the URL of the alert in the content database. The URL is updated to use the current URL of the site. After you perform this procedure, e-mail notifications that you receive will contain the correct URLs.



MORE INFORMATION
Administrators can programmatically update the URL of every alert that is created in a site collection. The following sample code updates the URLs of all alerts in a site collection.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. using System; using System.Collections.Generic; using System.Text; using Microsoft.SharePoint; using Microsoft.SharePoint.Administration; using Microsoft.SharePoint.Utilities;

namespace V3FixAlertsSiteUrl {   class V3FixAlertsSiteUrl {       static void Main(string[] args) {           string strSiteCollection = string.Empty;

// First (and only) argument is the URL to the Site Collection if (args.Length > 0) {               strSiteCollection = args[0];

try {                   using (SPSite spsitecol = new SPSite(strSiteCollection)) {                       using (SPWeb sprootweb = spsitecol.RootWeb) {                           ListAndFixAlerts(sprootweb); } // using sprootweb } // using spsitecol }               catch (System.IO.FileNotFoundException ioex) {                   Console.WriteLine(&quot;Could not access Site Collection: {0}&quot;, ioex.Message); }               catch (Exception ex) {                   Console.WriteLine(&quot;An unexpected error occurred: {0}&quot;, ex.Message); } // try }           else Console.WriteLine(&quot;No Site Collection URL was specified.&quot;);

}       //Enumerates all Alerts present on a Site Collection and modifies them //so that wrong information (for example, in the SiteUrl column) is corrected. static void ListAndFixAlerts(SPWeb spweb) {           Console.WriteLine(&quot;\n{0} Alert(s) for site: {1} ({2})&quot;, spweb.Alerts.Count, spweb.Title, spweb.Url);

foreach (SPAlert alert in spweb.Alerts) {               try {                   Console.WriteLine(&quot; {2} Alert \&quot;{0}\&quot; for user \&quot;{1}\&quot; \n  (Id: {3})\n&quot;, alert.Title, (alert.User != null ? alert.User.Name : &quot; &quot;), alert.AlertFrequency.ToString, alert.ID.ToString);

alert.Properties[&quot;siteUrl&quot;] = spweb.Site.Url; if (!String.IsNullOrEmpty(alert.Properties[&quot;MobileUrl&quot;])) alert.Properties[&quot;MobileUrl&quot;] = SPMobileUtility.GetApplicationPath(spweb);

try {                       alert.Update; }                   catch (Exception ex) {                       Console.WriteLine(&quot; -> Error changing Alert. {0}&quot;, ex.Message); } // inner try }               catch (Exception ex) {                   Console.WriteLine(&quot; An unexpected error occurred while accessing the Alert object: {0}&quot;, ex.Message); } // outer try } // foreach alert

//Handle all Sub-Webs recursively. if (spweb.Webs.Count > 0) {               for (int i = spweb.Webs.Count - 1; i >= 0; i--) {                   using (SPWeb spsubweb = spweb.Webs[i]) {                       ListAndFixAlerts(spsubweb); } // using spsubweb } //for subwebs } //if has subweb }

} }

Additional query words: rename link protocol different subscribe wss wss3.0 moss moss2007

Keywords: kbtshoot kbexpertiseinter kbprb KB936760

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.