SharePoint Document Workflow "How to" - Sending an email with SharePoint 2007 (MOSS)

As a part of the series that I am blogging on the "How To's" of Document Workflow in SharePoint 2007 (MOSS), here's a tip on how to send an email from your workflow using SharePoint Designer.  This is a long how to post, so my suggestion is to check out the recorded web cast first (see link below).  It takes less time to show you how to do it than it does to write up the steps.  After you've seen it done, the steps will be valuable to help you do it on your SharePoint site.

Here are the links to the existing blog entries and web cast recordings.

  • Click here to find all of the SharePoint/MOSS 2007 blog entries from my team
  • Click here to see my recorded web cast on Building Document Workflow's in MOSS 2007.
  • Click here to see the blog entry: How to enable the portal to receive external emails
  • Click here to to see the blog entry: How to extract an email address from an email sent to your Document Library for Workflow

In the entry labeled (above link) "How to extract an email address from an email sent to your Document Library for Workflow. "  I gave a detailed explanation of how to extract an email address from a document stored in a document library.  In this example, I will show how to use that email address (or a static email address) to send an email to a Person, Distribution Group, or dynamically based on the email address of the person who sent the document to the document library. 

My scenario, in case you have not read the earlier entries, is a resume processing workflow, in which people can email their resumes to some company ( and the workflow would run based on a new resume showing up in the document library.  This workflow step could be modified to ask the user for an email address to send to "using the Initiation button" (not shown here) or it could be "hard-coded" to send the email (with the attached document link) to a person or Distribution Link.

This demonstration presumes that you have access to SharePoint Designer.  If you do not, you can download an evaluation copy (see this article).

As a part of my resume processing scenario, I am sending an "Automated" email response to the applicant who sent their resume into our Job Site email address, using the email address attached to their resume in the document library and extracted and broken up into two parts (see my earlier article for why I broke the email up into two parts) .

Open SharePoint Designer to the site where the document library (associated with this workflow) exists.  Use the "Open Site" menu from the File Menu and put in the URL of your SharePoint Team Site, or wherever you document library exists.

  • Open your existing workflow, or create a new one.
  • Give the workflow a name (assuming that you've started a new Workflow)
  • Decide if you want the workflow to Manually, Automatically, or whenever an item is changed.
    • My suggestion is "Manually" while in development at the minimum.  This will keep you from having to continuously upload new documents to test the workflow.  You can upload one "test document" and keep using it, by manually starting the workflow on that document.
    • If you want "Automatic" starting of the workflow, turn that on after you are done testing/building, if you'd like, but if you are building this workflow on an "already existing" document library, you don't want your workflow to inadvertently run while you are building it, should someone put a file in the folder.
    • Be careful of the "Automatically item has changed" option, as this has some unintended consequences, which I will explain in a subsequent blog entry.

  • Hit the "Next Button" (Bottom Right)
  • Give the this step a name, like "Send an Automated Email Response"
  • The next thing that we need to do is to setup the "Conditions" and the "Actions"
    • In this case, we won't have a condition, because we want to always send an Automated email to the person who submits a resume.  I will talk more about conditions in a future blog entry, but if they are relatively simple to understand. 

Skip this step if you want to hard code an email address

    • First we need to get the email address from the SharePoint Document List, which as I've said before has been broken into two parts.  See this blog entry to understand why: How to extract an email address from an email sent to your Document Library for Workflow
      • In the article, I explained that you have to separate the email into 2 pieces to get past a SharePoint "issue" when dealing with email address and workflow.
      • So, we need to recombine the email address, into a normal email address, like:
      • We will use the "Build Dynamic String" Action to do this.
        • Choose the Action from the action menu
        • Set the Variable name to something that you will remember, like "Applicant Email Address". 


        • Click on the "dynamic string" link and recombine (concatenate) the email address back into one string, which will be stored in the workflow variable that you created ("Applicant Email Address" in my case).
        • When you click on it, you get a "String Builder" form like this one:

      • Hit the "Add Lookup" button (Bottom Left) to add the two SharePoint Custom Columns that we created, when we broke the email into two pieces (again, see the earlier post link above for details)
        • When you hit the "Add Lookup" button, you get the "Define Workflow Lookup" form
          • Select "Current Item" as the source, which refers to the SharePoint list that the workflow is attached to ("Incoming Resume" document library in my case)
          • Then select the variable that holds the first part of the email address as the field ( "WFV Email Address Part before @ Symbol", in my case.)
          • Hit the OK button to add that field
          • Now, without adding any spaces, do the same thing and add the second part of the email address, which in my case will be called "WFV Email Address Part from the @ Symbol on," which by the way, if you followed my suggestions on how to extract the email address will contain the "@" symbol in the email address and everything to the right of the @ symbol.

Your screen should look like this:


    • Hit the OK button
    • Next we add the "Send an Email" action. 

    • Select the this message link
    • Now you should have the "Define E-Mail Message" form open
    • Hit the "Address book" button on the "To" line.  BTW, if you wanted to hard code an email address, just type in in here and skip the next step.

    • Now, in the "Select Users" box, you can either select an:
      • Individual user
      • Email Distribution List
      • Multiple users (Hold down your CTRL key as you select each user)
      • or, all of the above

    • In our case, we are going to use the the "Workflow lookup" option to select our user from the Workflow variable "Applicant Email address" that we defined above.

    • Select "Workflow Lookup" and then hit the "Add >>" button (on the right) and your screen will now look like this:

    • Select "Workflow Data" as the "Source".  This will allow us to select the field that we built using the Build Dynamic String action (earlier).
    • Now, select the "Variable: Applicant Email Address" and hit the OK button to close the "Define Workflow Lookup"

  • Hit OK again, to close the "Select Users" Form

Your screen should look like this:

  • Now you can put in a message in the "Subject" Box
  • Put a message in the "Body" of the email
    • Note: If you wanted to send the link for the document (which in our scenario wouldn't make sense, because it would be a link to the internal portal) you would follow these steps:
      • Hit the "Add Lookup to Body" button
      • Choose "Current Item" as the Source
      • Choose "Encoded Absolute URL" as the field
      • Then wrap the whole thing in an HTML Link tag, so that it looks like this:

My screen looks like this (assuming that you do not want to include the document link):

  • Hit the OK button
  • If you want, you can Log the action, by using the "Log to Workflow history action" and enter a simple message, like "Send automated email response."
  • Click the "Check Workflow" button (button left), to make sure that you've made no mistakes.
  • Click the "Finish Button" (bottom right) to have the workflow attached to your SharePoint list (Document Library in my case)
  • Go back to your SharePoint Site and to your SharePoint List that has the workflow attached to it
  • Make sure that you have a document with an email address associated with it
  • Click on the document, and pull down it's "actions" menu.
  • Hit the "Workflow" Action

  • Select your workflow (Click on it)

  • Hit the Start Button (You wont get this page, unless you chose "Allow Manual Start of Workflow (earlier step)"

  • If everything worked, you should get see a "Workflow Completed" column on your SharePoint List and an Email should've been sent.


It took an over an hour to write this up with the screen shots and all, so now I am going to take a nap! :)


~ Robert Shelton