2009年10月28日

Sending Email with TSWA

TSWA has a function to send workitem as an email.

If TFS and smtphost are in the same domain(machine) and the TFSService account has enough permission to send email, it all right, just enable <emailSettings sendingEmailEnabled="true" enableSsl="false" /> is ok.

But if you want to use remote SMTP Server, set the value of

<system.net>
        <mailSettings>
            <smtp deliveryMethod="Network" from="…">
                <network defaultCredentials="false" host="SmtpHost" port="25" password="***" userName="name"/>
            </smtp>
        </mailSettings>

does not work.

As I use reflector to open EmailSettingsElement in Microsoft.TeamFoundation.WebAccess.Common.dll, I found that it use the property-value pair in <emailSettings>

public class EmailSettingsElement : ConfigurationElement
{
    // Fields
    private string m_smtpFrom;

    // Methods
    public EmailSettingsElement();

    // Properties
    [ConfigurationProperty("enableSsl", DefaultValue=false, IsRequired=false)]
    public bool EnableSsl { get; }
    [ConfigurationProperty("fromEmail", DefaultValue="", IsRequired=false)]
    public string FromEmail { get; }
    [ConfigurationProperty("sendingEmailEnabled", DefaultValue=false, IsRequired=true)]
    public bool SendingEmailEnabled { get; }
    public string SmtpFrom { get; }
    [ConfigurationProperty("smtpHost", DefaultValue="", IsRequired=false)]
    public string SmtpHost { get; }
    [ConfigurationProperty("smtpPassword", DefaultValue="", IsRequired=false)]
    public string SmtpPassword { get; }
    [ConfigurationProperty("smtpUsername", DefaultValue="", IsRequired=false)]
    public string SmtpUsername { get; }
}

 

So we can set the property-value pair in <emailSettings> to use remote smtp server like

<emailSettings sendingEmailEnabled="true" enableSsl="false" fromEmail="…"
                   smtpHost="SmtpHost" smtpPassword="***" smtpUsername="name"/>

Notice that “Port” is not specified in <emailSettings>, you can set it in  

<system.net>.<mailSettings>.

posted @ 2009-10-28 12:52 Ruiz 阅读(137) 评论(0) 编辑

<2009年10月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

导航

统计

公告

昵称:Ruiz
园龄:2年5个月
粉丝:1
关注:0

搜索

 
 

常用链接

我的标签

随笔分类

随笔档案

最新评论

阅读排行榜

评论排行榜

推荐排行榜