How Tfs sends emails - testing the smtp pipes

Published 22 November 05 10:39 AM | psheill 

If you are having trouble getting Tfs to send emails, one thing to test is connectivity and permission to send.  Sometimes the mail server will refuse to accept email if the sending account doesn't itself have a mailbox, or if the "from" address doesn't match the account that is connecting to the server. Log in as the service account, create a console application, copy and paste the following code, replace the first three strings with the appropriate values, compile and run it.  If it is a problem connecting to the mail server, you should get a good error message printed out.  Otherwise you should see the email appear in your inbox.

 

using System;
using System.Net;
using System.Net.Mail;

namespace MailSender
{

class Sender
{
    public static void Main(string[] args)
    {
        try
        {
            string Host = "myEmailServer";
            string FromAddress = "serviceAccount@somewhere.com";
            string ToAddress = "me@somewhere.com";
           
            SmtpClient client = new SmtpClient(Host);
            MailMessage mm = new MailMessage(FromAddress, ToAddress);
            mm.Body="TestBody";
            mm.Subject="TestSubject";
           
            client.UseDefaultCredentials = true;           
            mm.BodyEncoding = System.Text.Encoding.UTF8;
           
            client.Send(mm);
        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
        Console.ReadLine();
    }
   
}

}

Comments

# Mike, musorenko2003@yahoo.com said on December 22, 2005 4:15 PM:
I spent several hours trying to email from my 2005 C#, than I was lucky to find your place. Thanks a lot!!!
# Naren's Blog said on July 26, 2006 7:20 PM:

I was collecting links & pointers to answer common questions in forums related to TFS eventing...
# Naren's Blog said on October 12, 2006 8:16 PM:

I was collecting links & pointers to answer common questions in forums related to TFS eventing and

# SRLTeam said on November 10, 2006 2:25 AM:

Team System has a built-in, extendable alerting mechanism. It is based on SQL Server 2005 Notification

New Comments to this post are disabled
Page view tracker