Sharepoint 2013 创建TimeJob 自动发送邮件
创建Time Job
继承继承SPJobDefinition 并且实现里边的 Execute方法
部署
可以手动部署,把程序集放到GAC,手动激活feature
如果部署的时候说feature已经存在,在feature的XML里面添加代码 AlwaysForceInstall="TRUE",如下
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
AlwaysForceInstall="TRUE"
Title="Time Job for Find Document"
Description="Custom Feature for Time job">
</Feature>
安装
写到Feature,添加或者删除
更新
需要重新启动Windows SharePoint Services Timer 服务
调试
把OWSTIMER.EXE添加到进程
定义Timejob代码
引用
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Utilities;
public class FindDocument:SPJobDefinition
{
public FindDocument()
: base()
{
} public FindDocument(string jobName, SPWebApplication webapp)
: base(jobName, webapp, null, SPJobLockType.ContentDatabase)
{
this.Title = Constants.FDJobName;
} public override void Execute(Guid targetInstanceId)
{
SPWebApplication webapp = this.Parent as SPWebApplication;
SPContentDatabase contentDb = webapp.ContentDatabases[targetInstanceId]; string webUrl = this.Properties["WebUrl"].ToString();
using (SPSite site = new SPSite(webUrl))
{
using (SPWeb web = site.OpenWeb())
{
//Send mail to somebody
SPUtility.SendEmail(web, false, false,
"xxx@xxx.com", "E-mail title",
"E-mail body");
//udpate list
SPList list = web.Lists["Test"];
SPListItem item = list.Items[0];
item["Title"] = "Date " + DateTime.Now.ToString();
item.SystemUpdate();
}
}
} //If active feature error, please active feature manually.
protected override bool HasAdditionalUpdateAccess()
{
return true;
}
}
安装卸载Timejob代码
引用
using Microsoft.SharePoint.Administration;
public class TimeJobFeatureEventReceiver : SPFeatureReceiver
{
// Uncomment the method below to handle the event raised after a feature has been activated.
const string JobName = Constants.FDJobName;
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = properties.Feature.Parent as SPWeb;
DeleteJob(web); // Delete Job if already Exists
CreateJob(web); // Create new Job
} public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
DeleteJob(properties.Feature.Parent as SPWeb); // Delete the Job
} private static void DeleteJob(SPWeb web)
{
foreach (SPJobDefinition job in web.Site.WebApplication.JobDefinitions)
if (job.Name == JobName)
job.Delete();
} private static void CreateJob(SPWeb web)
{ TimeJob.Jobs.FindDocument job = new TimeJob.Jobs.FindDocument(JobName, web.Site.WebApplication);
job.Properties.Add("WebUrl", web.Url);
SPDailySchedule schedule = new SPDailySchedule();
schedule.BeginHour = 16;
schedule.BeginMinute = 00;
schedule.EndHour = 16;
schedule.EndMinute = 30;
job.Schedule = schedule;
job.Update();
}
}
Sharepoint 2013 创建TimeJob 自动发送邮件的更多相关文章
- SharePoint 2013创建WCF REST Service
SharePoint 2013为开发者提供了丰富的REST API,方便了我们在客户端操作List中的数据.当然我们也可以在SharePoint 2013中创建自定义的REST Service,比如通 ...
- SharePoint 2013 创建搜索中心及搜索设置
本文没有太多深奥的东西,只是简单的搜索配置,如果你已经掌握请略过本文. 好了,进入内容简介,众所周知,搜索是SharePoint一大特性,下面,我们简单介绍下搜索中心的创建. 1.创建Search子网 ...
- SharePoint 2013 创建一个搜索中心和搜索设置
这篇文章不是太多深奥的东西,只是一个简单的搜索配置,假设你已经有了,请跳过这篇文章. 行,输入信息,大家都知道,搜索SharePoint一个主要特征.下列,我们在搜索中心创建个人资料. 1.创建Sea ...
- SharePoint 2013 创建 Site Collection
在之前的文章中,通过SharePoint Central Administration 创建了Web Application.在这篇文章中将继续SharePoint 2013之旅——还是以Step B ...
- SharePoint 2013 创建Web Application
今天继续SharePoint 2013 的探索之旅,之前几篇文章分析了SharePoint 2013的物理拓扑结构,安装,以及逻辑体系结构.在这篇文章中,我将继续Step By Step形式演示如何在 ...
- sharepoint 2013创建外部内容类型并创建外部列表
步骤: 1.如何:基于 SQL Server 表创建外部内容类型 How to: Create an External Content Type Based on a SQL Server Table ...
- SharePoint 2013创建应用程序时IIS端口文件夹下没文件
最近SharePoint 2007迁移到2013的时候,碰到创建应用程序时IIS端口文件夹下没文件的问题,网上找了大把的原因,终于在这里找到了解决方案: Fix: 1. Open IIS on the ...
- sharepoint 2013 创建母版页
一.创建新的母版页, 并添加了新的样式表 1.从CodePlex 上获得Starter Master Pages for SharePoint 2010 或复制以下母版代码 <%@Master ...
- SharePoint 2013 创建web应用程序报错"This page can’t be displayed"
错误描述 This page can’t be displayed •Make sure the web address http://centeradmin is correct. •Look fo ...
随机推荐
- [C#]LDAP验证用户名和密码
测试环境:VS2008, NET Framework 3.5 公司打算改用LDAP来存储用户名和密码,现在用C#测试下如何能拿到LDAP中的用户名,并检测用户密码是否正确.即输入用户名和密码,可以检验 ...
- [转]非OpenVZ下利用谷歌TCP-BBR协议单边加速你的VPS
前段时间谷歌推出了新的 TCP-BBR 开源算法,可以起到单边加速 TCP 连接的效果,也就是不用客户端的配合,用来替代收费的锐速再合适不过,毕竟开源免费.TCP-BBR 的目的是要尽量跑满带宽,并且 ...
- 获得View的真实高度
// 标题 RelativeLayout view = (RelativeLayout) getLayoutInflater().inflate( R.layout.webviewheader, nu ...
- 【转】ContextMenuStrip菜单应用
测试可用的代码: #region 右键快捷菜单单击事件 private void contextMenuStrip1_ItemClick(object sender, EventArgs e) { T ...
- HTML5[6]:多行文本显示省略号
CSS3新增text-overflow: ellipse; 只支持单行文本 如果是多行文本, 在无法完全显示的情况下,可以按下面这样写: overflow:hidden; display: -webk ...
- 在server 2008/2003中 取消对网站的安全检查/去除添加信任网站
新安装好Windows Server 2003操作系统后,打开浏览器来查询网上信息时,发现IE总是“不厌其烦”地提示我们,是否需要将当前访问的网站添加到自己信任的站点中去:要是不信任的话,就无 ...
- [转]Visual Studio技巧之打造拥有自己标识的代码模板
可能经过很多博客的介绍,大家都知道代码段的使用,使用代码段可以很方便地生成一些常用的代码格式,确实对我们开发很方便.在团队开发中或者在某些情况下我们经常可能还会希望使用Visual Studio生成的 ...
- 红黑树(五)之 Java的实现
概要 前面分别介绍红黑树的理论知识.红黑树的C语言和C++的实现.本章介绍红黑树的Java实现,若读者对红黑树的理论知识不熟悉,建立先学习红黑树的理论知识,再来学习本章.还是那句老话,红黑树的C/C+ ...
- iOS-验证码倒计时60秒
一. 要求 1.点击获取验证码按钮,60秒倒计时,按钮变成不可点击状态,按钮文字变成倒计时的秒数. 2.当倒计时为0的时候,释放掉定时器NSTimer,按钮变成可以点击状态,按钮文字变成"获 ...
- HTTP状态码大全(转自wiki)
1xx消息 这一类型的状态码,代表请求已被接受,需要继续处理.这类响应是临时响应,只包含状态行和某些可选的响应头信息,并以空行结束.由于HTTP/1.0协议中没有定义任何1xx状态码,所以除非在某些试 ...