5

I have created a workflow process in Visio, then implemented it into the Tridion CMS where I am supposed to send some email notifications automatically.

Can anybody suggest to me how to send email notifications within a Tridion Workflow process using .NET/C#?

Also, what are the possible ways of managing email ids of sender and recipients that can be used to send an email?

4
  • 1
    What you tried so far? Commented Jan 31, 2014 at 10:32
  • I don't see anything about Workflow Process in your question except Title. Better you need to explain in a detailed way on what you are trying and what scenario you want to send email notification. Without this, its difficult to answer. Commented Jan 31, 2014 at 10:43
  • OK, let me volunteer to edit the question in a better way. Commented Jan 31, 2014 at 11:09
  • Please specify who you want to send emails to. Is it always to an Admin, or perhaps to the user who is assigned the task, or to all members of the group who the task is assigned to etc? Commented Jan 31, 2014 at 15:20

5 Answers 5

8

You should consider (at least put some thought) on using the Tridion Notification Framework: https://code.google.com/p/tridion-notification-framework

During the implementation often times, we try to tackle requirement at the moment and overlook the long term or future enhancements and maintainability. Having a framework like the above would help you even though it might slows you down in the beginning, but you will see great benefits in the future.

1
  • I hope the framework shouldn't slow anyone down - even in the beginning. It takes care of a fair amount of coding tasks that you'd have to do yourself. In any case, it's pretty well focussed on what the questioner is asking for. Commented Feb 3, 2014 at 18:50
5

Back in my consulting days I used to say that "sending emails is easy, determining who to send an email to is not". Guess it still applies.

The over-engineered way is to create a new schema for user profile management, and have someone maintain these components with user names and emails.

The nice way would be to extend the User UI to add an email field to it (and possibly store it in the user's AppData as part of the user profile), but this requires Anguilla skills that not many people possess (and the learning curve is steep).

The simple way is to change the user's "Description" field to include the email address for that user. I used this approach quite a lot, where the description for the users would "Nuno Linhares [[email protected]]". Then I could load the user object from my code, apply a simple RegEx and get the email address to send an email to.

1
  • I have always used the Description field. It makes things very simple. Commented Feb 3, 2014 at 16:45
2

When I wrote this functionality for YAWF (Yet Another Workflow Framework), I used individual components to store emails and multi-valued component links for groups of emails.

Sending emails is done using the standard .net APIs for email handling.

Have a look on Google for YAWF (Yet Another Workflow Framework) and you'll find a presentation and a webinar recording where I presented all that.

2

There could be many options but the quickest and simplest that can be used is the Event System code.

Where you can catch appropriate workflow events and write C# code to send an email.

Regarding web.config, Tridion CME itself is an ASP.NET based application and have its web.config and you are not supposed to make changes for such requirements.

I would suggest you read the Tridion Architecture, its different module and their connectivity before jumping on to the code and you will save a lot on the maintenance thing.

You may think of keeping email ids in Tridion components, metadata or maybe an additional .xml or .config file which will only be used by the Event System of SDL Tridion.

You may want to follow the process below for sending email on an activity finish:

  • Create an Event System for Workflow

     public class WorkflowEvent: TcmExtension
     {
    
     }
    
  • In the constructor, Subscribe the Finish Activity event as shown below:

     EventSystem.Subscribe< ActivityInstance, FinishActivityEventArgs> (WorkFlowSendEmail, EventPhases.Initiated);
    
  • Write the code in the callback function - WorkFlowSendEmail something as below:

     private static void WorkFlowSendEmail ( ActivityInstance subject, FinishActivityEventArgs args, EventPhases phase)
     {
        // Your Code to send email
     }
    
1

I understand that this is urgent, however, as Pankaj says, I would strongly advise that you consider the requirements fully, and choose the correct Tridion extension point (if appropriate), before you start coding this!

If you store the users' email addresses in Tridion (or a config file), then you will have to maintain these, and ensure that they are up to date, correct, etc.

If you are using Active Directory to authenticate your Tridion users, then I would recommend that you get the users' email addresses from AD. You could start by looking at this post on Querying Active Directory for User Emails in .NET.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.