5,693,062 members and growing! (18,485 online)
Email Password   helpLost your password?
Languages » VBScript » General     Intermediate

Auto notify your team members with email, when performing Visual Source Safe operations.

By Lone Developer

A Visual Source Safe Addin written in VB with the help of which you can auto-email your team members about the operations (Add, Check in, check out...) you performed on VSS
VBScript, .NET, WinXP, Windows, Visual Studio, Dev

Posted: 20 Jan 2006
Updated: 20 Jan 2006
Views: 24,940
Bookmarked: 18 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
9 votes for this Article.
Popularity: 3.56 Rating: 3.73 out of 5
3 votes, 33.3%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
3 votes, 33.3%
4
3 votes, 33.3%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Introduction

Me and five of my friends are working on a project. We use Visual Source Safe for our code. Last week an unfortunate incident happen with us, just a day before our project release. I found that the code which I checkined in VSS a day before was missing. When I asked my friends about this, we found that, one of them has unknowingly overwritten that piece of code in VSS with the one that he was working on.

Then we thought it would be better if in future we can auto-notify each other about our code add/checkin in VSS through some way. Then i read an article in msdn written in VC++ describing how we can intercept VSS events, while we perform any operation on them. Moreover i learnt about Outlook Redemption Library which help us to send emails programmatically bypassing security alert dialog boxes. With the help of this all i develop this simple VSS addin in Visual Basic.

After installing (which is as simple as this addin ) this addin, whenever you perform any operation on VSS a email will be send to all your friends. The email will be send when you logout from VSS and will consist of a summary of operations you have performed during that VSS session. The email will be send using the default email account configured in your Outlook. Moreover no security check dialog boxes will be shown during all this operation.

Prerequisite

  1. Outlook Redemption Library

Installation

  1. Copy the VSSVBAddin.dll into the %SystemRoot%\System32 folder.
  2. From a command prompt, register VSSVBAddin.dll with the following command
                            RegSvr32 VSSVBAddin.dll

     

  3. Create a file named Ssaddin.ini in the VSS\Win32 folder where the Ssapi.dll file is registered (in other words, the folder where you installed Visual SourceSafe). This folder should also be the folder that the following registry key points to:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SourceSafe\SCCServerPath
                            
  4. Open the Ssaddin.ini file and add the following line to it:
    VSSVBAddin.AddinClass = 1
  5. Create a file named maillist.txt in the folder where your Visual Source Safe Database srcsafe.ini is placed.
  6. Open the file and write the email id of all your team members one on each new line. e.g

        pradeep@xyz.com

        sudeep@pqr.com

        ....

Using the code

Visual source safe provides a method to trap and control it's various events such as BeforeAdd, BeforeCheckIn, .... through the use of addins. This code implements these events and whenever a operation is performed on VSS, it adds the details related to those operations to a global string variable str.

'Event fired after addition of any item.

Sub VSSHandler_AfterAdd(ByVal Item As IVSSItem, ByVal LocalSpec As _
String, ByVal Comment As String)
    'Check if any comment is added. then include that.

    If Comment <> "" Then
        str = str & vbCrLf & "Added: " & _
              Item.Parent.Spec & "/" & Item.Name & _
              " at : " & Now & ", Commented : " & Comment
    Else
        str = str & vbCrLf & "Added: " & _
              Item.Parent.Spec & "/" & _
              Item.Name & " at : " & Now
    End If
End Sub

Later on when user exits the VSS , Class_Terminate is called. Here we read the mail id of all the recipients from maillist.txt file placed on the same path as srcsafe.ini file of VSS database itself. Then we send a mail to all those recipient using Redemption Library (which uses your default email account configured on Outlook).

Private Sub Class_Terminate()
    On Error GoTo Mailing_Error
    'Check if any operation is done. else this string will be empty

    If str <> "" Then
        Dim SafeItem, oItem

        'Creates a mail item to be mailed.

        Set Application = CreateObject("Outlook.Application")
        Set Namespace = Application.GetNamespace("MAPI")
        Namespace.Logon

        Set SafeItem = CreateObject("Redemption.SafeMailItem")
        Set oItem = Application.CreateItem(0)
        SafeItem.Item = oItem

        'Reads maillist.txt file for recipient address.

        Dim nFileNum As Integer, sNextLine As String
        'Get free file number

        nFileNum = FreeFile

        'Opens the file

        Open Left$(VSSHandler.VSSDatabase.SrcSafeIni, _
             Len(VSSHandler.VSSDatabase.SrcSafeIni) - 11) _
             & "maillist.txt" For Input As nFileNum
        Do While Not EOF(nFileNum)
            'Read recipient mail id

            Line Input #nFileNum, sNextLine

            'Add email recipient

            SafeItem.Recipients.Add sNextLine
        Loop

        ' Close the file

        Close nFileNum

        'Resolves email ids

        SafeItem.Recipients.ResolveAll
    
        'Create the subject of mail

        SafeItem.Subject = "VSS Notification - " & _
                            VSSHandler.VSSDatabase.SrcSafeIni

        'Create the body of email

        str = "This is an auto generated message." & vbCrLf & _
              "User :" & VSSHandler.VSSDatabase.Username & _
              ", performed the following operations on VSS Database " _
              & vbCrLf & str
        SafeItem.Body = str

        'Send the email

        SafeItem.Send

        'Used in case of non Exchange Server mailids e.g. pop-smtp... _

        to immidiately deliver mail
        Set Utils = CreateObject("Redemption.MAPIUtils")
        Utils.DeliverNow
    End If

    Exit Sub
    'Handle any error here.

Mailing_Error:
    MsgBox "Error " & Err.Number & " while sending mail" & vbCrLf & Err.Description
End Sub

Related Links:

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Lone Developer



Occupation: Software Developer (Senior)
Location: India India

Other popular VBScript articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 13 of 13 (Total in Forum: 13) (Refresh)FirstPrevNext
GeneralQuestionmemberJasmin Ahuja2:20 24 Sep '08  
GeneralRe: QuestionmemberAmitabh Khan2:21 24 Sep '08  
GeneralRe: QuestionmemberShahrukh Bachhan2:25 24 Sep '08  
GeneralGood One!memberRajesh Kumar Bhalla2:18 24 Sep '08  
GeneralTool to send automated mails for VSSmemberShane82828:43 12 Oct '07  
GeneralRe: Tool to send automated mails for VSSmemberLone Developer6:49 27 Aug '08  
GeneralNo mails receivedmemberArvind151:52 28 Feb '07  
QuestionSource Safememberme_ranjit2:53 31 Jul '06  
Generalquestionmemberkarthieyan22:39 26 Mar '06  
GeneralQuestionmembercarlopagliei7:31 25 Jan '06  
GeneralRe: QuestionmemberHimanshu Agarwal9:22 25 Jan '06  
GeneralNice thought !!memberTittle Joseph23:12 20 Jan '06  
GeneralRe: Nice thought !!memberBrad Bruce2:11 21 Jan '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 20 Jan 2006
Editor:
Copyright 2006 by Lone Developer
Everything else Copyright © CodeProject, 1999-2008
Web08 | Advertise on the Code Project