用代码取得SPList的传入电子邮件地址

 

      SPList的传入电子邮件地址由两个部分组成,“@”之前的SPList.EmailAlias(目前为止(2009-4-13MSDN上关于EmailAlias的说明是错误的!)和“@”之后的MOSS的出站SMTP服务器地址。废话少说,直接上代码吧!

代码实现:

using (SPSite mySPSite = new SPSite("<SPSiteURL>"))

            {

                using (SPWeb spRootWeb = mySPSite.RootWeb)

                {

                    string mailAdress=string.Empty;

                                          //取得@后面的部分

                    SPIncomingEmailService spMail =
                                    (SPIncomingEmailService)SPFarm.Local.GetChild<SPIncomingEmailService>();

                    string mailDomain = spMail.ServerDisplayAddress;

                    SPList spList = spRootWeb.Lists["<SPListTitle>"];

                                          //取得SPList的传入电子邮件地址

                    mailAdress = spList.EmailAlias + "@" + mailDomain;

                    Console.WriteLine(mailAdress);

                    Console.ReadLine();

                }

            }

附:MSDN上关于SPList.EmailAlias属性的解释:
If e-mail notification is enabled, gets or sets the e-mail address to use to notify to the owner of an item when an assignment has changed or the item has been updated.

http://msdn.microsoft.com/zh-cn/library/microsoft.sharepoint.splist.emailalias.aspx

 

posted on 2009-04-13 14:06  阿米巴原虫  阅读(418)  评论(0编辑  收藏  举报