Sharepoint知识点收集Word文档格式.docx
《Sharepoint知识点收集Word文档格式.docx》由会员分享,可在线阅读,更多相关《Sharepoint知识点收集Word文档格式.docx(21页珍藏版)》请在冰豆网上搜索。
n"
"
<
br/>
识别为垃圾邮件
来历不明的软件发的邮件都是垃圾邮件。
所以发邮件的时候要套个马甲。
这个代码就是套个OutLook作掩护。
publicboolSend(stringSubject,stringBody,stringTo,stringMailFrom,stringMailFromName,stringMailDomain,stringMailServerUserName,stringMailServerPassWord)
{
try
MailMessagemsg=newMailMessage();
msg.From=newMailAddress(MailFrom,MailFromName);
msg.To.Add(newMailAddress(To,To));
msg.Subject=Subject;
msg.Body=Body;
msg.IsBodyHtml=true;
msg.Priority=MailPriority.Normal;
msg.SubjectEncoding=System.Text.Encoding.UTF8;
msg.BodyEncoding=System.Text.Encoding.UTF8;
//以下附加头用于避免被识别为垃圾邮件
msg.Headers.Add("
X-Priority"
3"
X-MSMail-Priority"
Normal"
X-Mailer"
MicrosoftOutlookExpress6.00.2900.2869"
X-MimeOLE"
ProducedByMicrosoftMimeOLEV6.00.2900.2869"
ReturnReceipt"
1"
//附加结束
SmtpClientclient=newSmtpClient(MailDomain);
client.UseDefaultCredentials=false;
client.Credentials=newNetworkCredential(MailServerUserName,MailServerPassWord);
//帐号密码
client.DeliveryMethod=SmtpDeliveryMethod.Network;
client.Send(msg);
returntrue;
}
catch{returnfalse;
使用MOSS自带的方法发送email
StringDictionarymessageHeaders=newStringDictionary();
messageHeaders.Add("
to"
email);
subject"
s_subject);
//messageHeaders.Add("
from"
content-type"
text/html"
cc"
bcc"
SPUtility.SendEmail(this.Web,messageHeaders,s_body);
.net方式发送email
publicstaticboolSendMail(stringto,stringsubject,stringbody)
MailAddressfrom=newMailAddress("
MOSS-Test1@XXX.com"
MailAddresstoUser=newMailAddress(to);
MailMessagemailobj=newMailMessage(from,toUser);
//完善MailMessage对象
mailobj.Subject=subject;
mailobj.Body=body;
mailobj.IsBodyHtml=true;
mailobj.BodyEncoding=System.Text.Encoding.GetEncoding("
UTF-8"
mailobj.Priority=MailPriority.Normal;
//构建SmtpClient对象
SmtpClientsmtp=newSmtpClient("
try
smtp.Send(mailobj);
catch
returnfalse;
}
我们使用.NET类库中的API发Mail的时候,我们要配置他的SMTPServer等,但是在Sharepoint里,已经提供了相关的封装的方法:
SPUtility.SendEmail(SPWeb,false,false,"
to@"
MailTitle"
"
MailBody"
上面的方法只能以To的形式来发Mail,有的时候我们需要使用CC,BCC,我们可以利用该函数的另一个重载来实现:
SPUtility.SendEmail(web,messageHeaders,messageBody,appendFooter)
我们需要设置messageHeaders,代码如下:
StringDictionaryheaders=newStringDictionary();
headers.Add("
To"
To@M"
CC"
CC@M"
Bcc"
BBC@M"
From"
From@M"
TheMailTitle"
在header中可以指定ToCCBCCFrom等,当然使用上面的函数的前提是你在管理中心已经配置好了传出电子邮件的设置。
更新工作流状态
SPList
list
=
web.List["
TestList"
];
SPListItem
listItem
list.GetItemById
(1);
string
state
listItem.Fields["
审批状态"
].InternalName;
listItem[state]
0;
//设置列表审批状态为“已批准”(0表示
已批准)
listItem.SystemUpdate();
//列表使用SystemUpDate()方法来更新审批状态。
//文档库
SPDocumentLibrary
docLib
TestLib"
libItem
libItem.Fields["
libItem[state]
//设置文档库审批状态为“已批准”(0表示已批准)
libItem.UpdateOverwriteVersion();
//文档库使用UpdateOverwriteVersion()方法来更新审批状态。
item["
_ModerationStatus"
]=(int)SPModerationStatusType.Approved;
item.Update();
这样好像就可以
string转Guid
Guiddd=newguid(str);
ContentType
Item[“ContentTypeId”]或者Item[“ContentType”]
显示个人信息
用SPD打开根站点
在根下
_catalogs
目录有users(用户信息表)
此表是网站集所管理的用户列表。
默认为隐藏。
点右键属性--设置--钩掉“在浏览器中隐藏”选项。
此时,用户表就可以像其他列表一样操作
要实现显示照片和姓名职务部门等信息
可以通过webpart显示指定列信息,转换为XSLT视图,进行定制
注意设置筛选条件为:
ID列=
[当前用户]
最终可以自由定制。
Item.SystemUpdate();
方法
更改时间
更改者
事件
更改和审核记录
订阅
propertiesarenotdemotedintodocuments
增加版本
SystemUpdate()
×
√
SystemUpdate(Bool)
False不增加
长时间操作,不超时
SPLongOperationoparetion=newSPLongOperation(this);
oparetion.Begin();
//启动工作流
//StartInitData参数为ApproveWFAssociationData类的序列化后的string
web.Site.WorkflowManager.StartWorkflow(listItem,workflowAssociation,StartInitData());
catch(Exceptionex)
thrownewException(ex.ToString());
oparetion.End(list.DefaultViewUrl);
finally
if(oparetion!
=null)
oparetion.Dispose();
转向
//转向到该list的工作流设置页面
SPUtility.Redirect("
WrkSetng.aspx?
List="
+taskList.ID,
SPRedirectFlags.RelativeToLayoutsPage,HttpContext.Current);
转到错误页
SPUtility.TransferToErrorPage("
TheCreateChildControlsfunctionoftheAjaxBaseParthasnotbeencalled.
Youprobablyneedtoadd"
base.CreateChildControls()"
tothetopofyourCreateChildControlsoverride."
成员名称
说明
CheckUrl
ChecktheredirectUniformResourceLocator(URL).
Default
Usedefaultsettingsfortheredirect.
DoNotEncodeUrl
DonotencodetheredirectURL.
DoNotEndResponse
Donotendtheresponseaftertheredirect.
RelativeToLayoutsPage
相对Layouts的地址Theredirectoccursrelativetothelayoutspage.
RelativeToLocalizedLayoutsPage
相对触发的layouts中Page的地址Theredirectoccursrelativetothelocalizedlayoutspage.
Static
静态地址,非相对地址Theredirectisstatic.
Trusted
Theredirectistrusted.
UseSource
使用URL中的Source的地址Usethesourcefortheredirect.
内容类型
SPWeb.AvailableContentTypes得到当前web所有活动的内容类型
SPWeb.ContentTypes得到部署到当前web上的内容类型,不要用这个。
Web的用户list
web.SiteUserInfoList
AD操作
DirectoryEntrydi=newDirectoryEntry("
LDAP:
//ADServer/OU=开发部,administrator,pass,AuthenticationTypes.Secure);
广州㊣-jian(简)说:
这句应该是最关键的了
然后想在“开发部”下面增加用户,就用di.Children.Add就可以了
List附件的读取
怎么取得sharepoint表单库中的表单附件的数据,我想将附件数据单独的提取出来,但是提取的信息全是BASE64编码,有没有这方面的信息或资料,
BASE64解码不就完了
System.Convert.FromBase64String
模拟用户代码
stringsiteUrl="
:
82/sites/sjs"
;
//首先用管理员身份取到某个用户的Token,必须,非管理员无法模拟
SPSitesite=newSPSite(siteUrl);
//此时用户为SHAREPOINT"
system
Response.Write(site.RootWeb.CurrentUser);
SPUseruser=site.RootWeb.SiteUsers["
saicmotorlab"
user1"
//利用用户Token构造新的Site对象
SPSitesiteWithUser=newSPSite(siteUrl,user.UserToken);
SPWebwebWithUser=siteWithUser.RootWeb;
//此时用户为SAICMOTORLAB"
user1
Response.Write(webWithUser.CurrentUser);
SPListlistWithUser=webWithUser.Lists["
simeList"
//dothercode
PeopleEditor控件
PeopleEditor.SelectionSet="
User,DL,SecGroup"
;
代表可以选择用户,也可以选择组
工作流历史记录表
http:
//cnsh-10apl1/ProjectManagement/Lists/WorkflowHistory/
Infopath中为下拉框添加值
testNode.AppendChildElement(testNode.Prefix,"
AddElm"
testNode.NamespaceURI,string.Empty);
AJAX实现
3:
在相关MasterPage的<
head>
里添加
scripttype='
text/javascript'
>
_spOriginalFormAction=document.forms[0].action;
_spSuppressFormOnSubmitWrapper=true;
/script>
4.在你写好的UserControl的Page_load事件里添加
if(this.Page.Form!
stringformOnSubmitAtt=this.Page.Form.Attributes["
onsubmit"
if(formOnSubmitAtt=="
return_spFormOnSubmitWrapper();
this.Page.Form.Attributes["
]=
_spFormOnSubmitWrapper();
ScriptManager.RegisterStartupScript(this,
typeof([你UserControl的ClassName]),"
UpdatePanelFixup"
_spOriginalFormAction=
document.forms[0].action;
_spSuppressFormOnSubmitWrapper=true;
true);
当PersonorGroup字段允许多人时,通过sdk对象读取用户信息
List<
SPUser>
users=newList<
();
SPGroup>
groups=newList<
SPFieldUserValueCollectionvalues=(SPFi