我需要通过Windows应用程序(C#)检索我可以访问的所有SharePoint站点的列表.我打算使用SharePoint Web服务.
使用SharePoint Web服务的任何指针都可以为我提供所需的信息?
我的问题是特定于Send-MailMessagecmdlet的,但我认为这适用于Powershell.
我有一个命令发送一封如下所示的电子邮件:
Send-MailMessage -From $FROM_EMAIL_ADDRESS -To $to -Subject $subject -Body $message -SmtpServer $EMAIL_SERVER
Run Code Online (Sandbox Code Playgroud)
这没什么特别的,定义了此命令中使用的所有变量.
我还有另一个变量$cc,可能有也可能没有值.如果我进行与上面相同的调用追加-Cc $cc到结尾,当$cc为空时我得到一个错误,该命令不能接受该参数的空值.
所以我必须这样做才能克服错误:
if ($cc -eq "")
{
# Email command without the CC parameter.
Send-MailMessage -From $FROM_EMAIL_ADDRESS -To $to -Subject $subject -Body $message -SmtpServer $EMAIL_SERVER
}
else
{
# Email command with the CC parameter.
# This is exactly the same call as above, just the CC param added to the end.
Send-MailMessage -From $FROM_EMAIL_ADDRESS -To $to …Run Code Online (Sandbox Code Playgroud) 我有一个函数,它接受一个序列化的字符串,打破字符串以构建它定义的许多对象,然后返回一个通用列表.这是函数,它正如我需要的那样工作:
// 'T' only supports specific types - those derived from BaseObject.
internal static T[] DeserializeData<T>(string serializedData)
{
var data = new List<T>();
// Break into individual serialized items and decode each.
foreach (var serializedItem in (serializedData ?? "").Split(','))
{
// Skip empty entries.
if (serializedItem == "")
{
continue;
}
// Base class which 'T' will always be derived from.
BaseObject item = null;
// Initialize object based on the generic type provided.
if (typeof(T) == typeof(BaseObjectSpecific1))
{
item …Run Code Online (Sandbox Code Playgroud)