1

I have server plugin for TFS which send mail when something is assign to person.

Now what I have to do is, my plugin will send the mail on history change. example:

(mak) have assigned a bug to (betty). betty change the state of bug and assigned to (maddi) so my server plugin will send the assign to mail.First for (betty) and then for (maddi), now i want that it will send the history change alert to (mak). how can i achieve this goal? My code is below with all fields.

string mailbody ="";
mailbody += "<body><div class='Title'><b><a href={0}>Work item:{1}&nbsp;{2} - {3}</a></b></div><br />";
mailbody += "<table>{4}</table><br/><br />Other fields <table class='WithBorder'>{5}</table>";
string mailfooter = "<div class=footer><br />Notes:<br />- All dates and times are shown in GMT+05:00:00 Pakistan Standard Time<br />- You are receiving this notification because of a subscription created by SHMA\\Fahad.Ali<br />Provided by <a HREF='http://go.microsoft.com/fwlink/?LinkID=129550'title='Microsoft Visual Studio® Team System 2010'>Microsoft Visual Studio® Team System 2010</a></div></body>";
string mailsubject = "{0} Work Item : {1} {2} - {3}";

StringBuilder wiMessage = new StringBuilder("", 500);
StringBuilder wiSubject = new StringBuilder("", 200);

if (AssignedToChange)
{
    string otherData = "", codeData = "";

    foreach (StringField field in workItemChange.CoreFields.StringFields)
    {
      codeData += "<tr ><td class='PropName'>" + field.Name + "</td><td class='PropName'>" + field.NewValue + "</td></tr>";                        
    }

    otherData += "<tr width=100%><td class='ColHeadingMedium'>Field              </td><td class='ColHeading'>New Value              </td><td class='ColHeading'>Old Value              </td></tr>";
    foreach (StringField field in workItemChange.ChangedFields.StringFields)
    {
      otherData += "<tr><td class='ColHeadingMedium'>" + field.Name + "</td><td class='ColHeadingMedium'>" + field.NewValue + "</td><td class='ColHeadingMedium'>" + field.OldValue + "</td></tr>";
    }

    wiMessage.AppendFormat(mailbody,  workItemChange.DisplayUrl,
                           "", witem.Id, witem.Title, codeData, otherData);

    wiMessage.AppendLine(mailfooter);
    wiSubject.AppendFormat(mailsubject, workItemChange.PortfolioProject, "",witem.Id,witem.Title);
    SendEmail(assTo, wiSubject.ToString(), styleTag + wiMessage.ToString());
}
Mike Zboray
  • 39,828
  • 3
  • 90
  • 122
Syed Ali
  • 279
  • 1
  • 4
  • 15

0 Answers0