SPAlert class
代表會產生定期的電子郵件或短訊息服務 (SMS) 通知傳送給使用者清單、 清單項目、 文件或警示所套用的文件庫的相關警示。
Inheritance hierarchy
System.Object
Microsoft.SharePoint.SPAlert
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public NotInheritable Class SPAlert
'用途
Dim instance As SPAlert
public sealed class SPAlert
備註
SPAlert提供資訊警示,例如使用哪一警示的範本時,提醒的頻率,並建立提醒的使用者UserID 。
使用的SPUser或SPWeb類別的Alerts屬性,傳回SPAlertCollection物件,表示集合的使用者或網站的提醒。若要從集合傳回單一警示,請使用索引子。
注意事項 |
---|
之後對警示的任何變更,請使用Update方法。 |
Examples
這個程式碼範例會使用SPAlert類別來逐一查看每個使用者的站台的所有提醒並更新提醒的頻率。
Dim site As SPWeb = SPControl.GetContextWeb(Context)
Dim users As SPUserCollection = site.Users
Dim user As SPUser
For Each user In users
Dim alerts As SPAlertCollection = user.Alerts
Dim alert As SPAlert
For Each alert In alerts
alert.AlertFrequency =
Microsoft.SharePoint.SPAlertFrequency.Immediate
alert.Update()
Next alert
Next user
SPWeb oWebsite = SPContext.Current.Web;
SPUserCollection collUsers = oWebsite.Users;
foreach (SPUser oUser in collUsers)
{
SPAlertCollection collAlerts = oUser.Alerts;
foreach (SPAlert oAlert in collAlerts)
{
oAlert.AlertFrequency =
Microsoft.SharePoint.SPAlertFrequency.Immediate;
oAlert.Update();
}
}
注意事項 |
---|
某些物件實作IDisposable介面,並且您必須避免之後不再需要保留這些物件在記憶體中。良好的程式碼撰寫方式的相關資訊,請參閱Disposing Objects。 |
Thread safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.