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 on 2009-10-28 12:52  Ruiz  阅读(398)  评论(0编辑  收藏  举报

导航