On the fly email notifications

A common PDMWorks Enterprise enhancement request is to give the users the ability to pick and choose who gets notified when a document goes through a workflow transition.

While personally that request seems like it would make a loophole users could use to get around the system i.e. not notifying your manager or quality control if a document is approved. -I’ll grant there may be cases where it would be useful.

So I thought I’d give you a little application that could be used to get you started in creating your own. There are fancier ways this could be done but this provides a very flexible solution and the price is right eh?

The program would be kicked off as an “action” as a document goes through a transition. [As an example see screen shot.]


Note the full file name is sent as a command line argument using the “File Path” tag. This is how the file name gets sent to the program. Additionally, ensure the compiled .exe program is in a location where everyone has access to it.

Once started by the PDMWorks Enterprise transition, this routine simply creates a pre-populated Outlook message -populated with anything you choose. Typically the body of the message wouldn’t need to contain much -mostly just containing a link to the file that triggered the routine and some minimal instructions. The user would then, in this Outlook message, choose who to send the email to. He could also modify the body of the email if he chose. Then when the email looks as he likes he simply clicks “send”.

Here is the .NET code. Feel free to modify it to fit your needs, just keep the first comment line in! 🙂

Imports Microsoft.Office.Interop
Imports Microsoft.VisualBasic
Module modMain
Public Sub Main()
'by Jeff Sweeney, may he live long and prosper
Dim strFileName As String = Interaction.Command()
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objMailFolder As Outlook.MAPIFolder
Dim objMailItem As Outlook.MailItem
objOutlook = CreateObject("Outlook.application")
objNameSpace = objOutlook.GetNamespace("MAPI")
objMailFolder = objNameSpace.GetDefaultFolder(4)
objMailItem = objMailFolder.Items.Add
objMailItem.Subject = "A file needs your approval"
objMailItem.HTMLBody = strFileName & " has gone through a transition and requires you to do something"
objMailItem.Display()'gives the user a chance to modify
objMailItem = Nothing
objMailFolder = Nothing
objNameSpace = Nothing
objOutlook = Nothing
End Sub
End Module

Tip: Don’t forget you will need to add Outlook as a reference in your .NET project. Otherwise simply compile as a “Console Application” and you are set!

This is just the tip of the iceberg. You could change the routine to accept more than one parameter. An additional parameter could be the transition name, so you could get different emails depending on the transition that called it. You could have the routine examine the extension of the file and do different things depending on the file’s extension.

I’d love to learn how you end up using it!

  • Share this
Find Your Design Solution in the CATI Store.
Browse Products