共用方式為


Alerts.DeleteAlerts Method

Deletes the specified alerts within a Web site.

Namespace:  [Alerts Web service]
Web service reference: http://Site/_vti_bin/Alerts.asmx

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/DeleteAlerts", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/",  _
    ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function DeleteAlerts ( _
    IDs As String() _
) As DeleteFailure()
'Usage
Dim instance As Alerts
Dim IDs As String()
Dim returnValue As DeleteFailure()

returnValue = instance.DeleteAlerts(IDs)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/DeleteAlerts", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/", 
    ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public DeleteFailure[] DeleteAlerts(
    string[] IDs
)

Parameters

  • IDs
    Type: []

    A string array that contains the GUIDs of alerts to delete.

Return Value

Type: []
A DeleteFailure array that contains the alert ID and error status of unsuccessful deletions.
To access the Alerts service and its methods, set a Web reference to https://Server_Name/[sites/][Site_Name/]_vti_bin/Alerts.asmx.

Examples

The following code example deletes all the alerts from the current site.

Dim alertService As New Web_Reference_Folder_Name.Alerts()
alertService.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim alertInfo As Web_Reference_Folder_Name.AlertInfo = alertService.GetAlerts()
Dim alerts As Web_Reference_Folder_Name.Alert() = alertInfo.Alerts
Dim delString(alerts.Length) As String
Dim i As Integer

For i = 0 To delString.Length - 1
    delString(i) = alerts(i).Id.ToString()
Next i
Try
    alertService.DeleteAlerts(delString)
    Catch ex As Exception
        MessageBox.Show(ex.Message)
End Try
Web_Reference_Folder_Name.Alerts alertService = new Web_Reference_Folder_Name.Alerts();
alertService.Credentials= System.Net.CredentialCache.DefaultCredentials;

Web_Reference_Folder_Name.AlertInfo alertInfo = alertService.GetAlerts();
Web_Reference_Folder_Name.Alert[] alerts = alertInfo.Alerts;

string[] delString = new string[alerts.Length];

for (int i=0; i<delString.Length; i++)
{
    delString[i] = alerts[i].Id.ToString();
}
try
{
    alertService.DeleteAlerts(delString);
}
catch(Exception ex)
{
    MessageBox.Show(ex.Message);
}

The example uses the GetAlerts method to return information about the alerts, assigns the returned information to an array of alerts, and assigns the GUID of each alert in the array to a string array that is passed to the DeleteAlerts method.

See Also

Reference

Alerts Class

Alerts Members

Alerts Web Service