我目前正在构建一个自动创建SharePoint站点的工具。每个站点都必须启用邮箱并指定特定的电子邮件地址。
我可以创建一个默认情况下有一个名为“SharePoint”的邮箱列表的站点。
我的问题是如何允许“邮箱”SPList接收电子邮件。SPList中有一个名为CanReceiveEmail的属性,但它是只读的吗?那么有没有别的办法呢?
我还需要能够以编程方式设置SPList的电子邮件地址,有谁知道最好的方法来做到这一点?
它可以手动完成,但这不是一个选项。
发布于 2010-01-08 00:41:22
一个简单的列表(据我所知,但我可能是错的)不能接收电子邮件。您可以创建一个自定义列表。
您可以创建文档库,默认情况下文档库具有此功能。
当你检查/_layouts/EmailSettings.aspx的代码(使用Lutz Roeder's Reflector,http://www.red-gate.com/products/reflector/)时,你可以看到这些属性是如何设置的,这些代码可以在服务器上的"Microsoft.SharePoint.ApplicationPages.dll“中找到,路径类似于\\server\c$\Inetpub\wwwroot\wss\VirtualDirectories\80\_app_bin。因此,您必须设置文档库的“根文件夹”的多个属性。
代码如下:
Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal args As EventArgs)
If Me.EnabledTrue.Checked Then
If ((Me.TxtAlias.Text Is Nothing) OrElse (Me.TxtAlias.Text.Length = 0)) Then
Throw New SPException(SPResource.GetString("MissingEmailAlias", New Object(0 - 1) {}))
End If
'This will be the receiving e-mail address
Me.m_List.EmailAlias = Me.TxtAlias.Text
'do we need to check users permissions on items
Me.m_RootFolder.Properties.Item("vti_emailusesecurity") = IIf(Me.UseSecurityTrue.Checked, 1, 0)
If Me.ShowSaveAttachments Then
'options how to save attachments, root folder, grouped, whatever
Me.m_RootFolder.Properties.Item("vti_emailsaveattachments") = IIf(Me.SaveAttachmentsTrue.Checked, 1, 0)
End If
If Me.ShowSaveOriginalAndMeetings Then
Me.m_RootFolder.Properties.Item("vti_emailsavemeetings") = IIf(Me.MeetingsTrue.Checked, 1, 0)
Me.m_RootFolder.Properties.Item("vti_emailsaveoriginal") = IIf(Me.SaveOriginalTrue.Checked, 1, 0)
End If
If Me.ShowAttachmentFolders Then
Me.m_RootFolder.Properties.Item("vti_emailoverwrite") = IIf(Me.OverwriteTrue.Checked, 1, 0)
If Me.AttachmentFoldersSender.Checked Then
Me.m_RootFolder.Properties.Item("vti_emailattachmentfolders") = "sender"
ElseIf Me.AttachmentFoldersSubject.Checked Then
Me.m_RootFolder.Properties.Item("vti_emailattachmentfolders") = "subject"
Else
Me.m_RootFolder.Properties.Item("vti_emailattachmentfolders") = "root"
End If
End If
If Me.ShowAutoApprove Then
'I think this is something when content approval is enabled.
Me.m_RootFolder.Properties.Item("vti_emailautoapprove") = IIf(Me.AutoApproveTrue.Checked, 1, 0)
End If
ElseIf Me.EnabledFalse.Checked Then
Me.m_List.EmailAlias = Nothing
End If
Me.m_RootFolder.Update
Me.m_List.ResetContentTypes
Me.m_List.Update
SPUtility.Redirect((IIf((Me.m_List.BaseType = SPBaseType.Survey), "survedit", "listedit") & ".aspx?List=" & Me.m_List.ID.ToString), SPRedirectFlags.RelativeToLocalizedLayoutsPage, Me.Context)
End Sub编辑:在我的代码中添加注释
https://stackoverflow.com/questions/2021854
复制相似问题