Welcome to MSDN Blogs Sign in | Join | Help

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 (jobs@somecompany.com) 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 Start....an 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: someone@somecompany.com
      • 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". 

IS CHANGED TO....

        • 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

Published Tuesday, May 22, 2007 2:58 PM by Public Sector DPE Team

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# links for 2007-05-29 » mhinze.com

Tuesday, May 29, 2007 11:28 AM by links for 2007-05-29 » mhinze.com

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

Tuesday, June 12, 2007 5:21 PM by zullu

Hi,

I am working on MOSS 2007 with InfoPath 2003.

I have a workflow where a Infopath form is submitted by a user in the Form Library. Upon submission I am trying to send a mail to his manager. The mail needs to have the link of the form which has been submitted.

I can see the link when I hover my mouse on the form (which looks like:

"http://myserver/sites/mydocLibrary/myInfoPathForm.xml").

How do I dynamically capture this link in the workflow to send it in the email content.

There is something known as "Absolute URL".

But not sure how to make use of it.

Any help !!!

Thanks,

zullu.

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

Wednesday, June 13, 2007 6:35 AM by Jackie Kearney

Hi All,

Do you know if instead of adding a link to the document, you can attach the document to the email you are sending out?

Thanks

# Can I send documents from sharePoint to the email

Wednesday, June 13, 2007 2:50 PM by Ravi

Now suppose the resume is added to the library and instead of sending out a plain response I want to send back some attachments back to the candidate.

Based on the department the resume is addressed to I want to send the attachment. For instance if the job application is for the IT department I want Sharepoint to send back documents related to IT department.

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

Tuesday, June 19, 2007 5:43 PM by zullu

Hi Robert,

You are logging the workflow steps in the above workflow in a history log.

Any idea of where are these getting logged.

Where do I see these entries getting logged, which file? which location?

this is getting too messy with me.

Please respond,

Thanks!

zullu.

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

Friday, June 22, 2007 9:29 AM by Clayton

Zullu, the workflow history is logged in the Workflow Status page.  You there by clicking on the hyperlinked status (e.g. "Completed") beneath your new workflow column.  When you click on that link, it takes you to the workflow status page for the current or most recent worfklow.  On that page, you see all tasks assigned during the workflow, the task status, and the workflow history log at the bottom with every step that was logged.  Then, there should also be a link to View Workflow History Reports, which is where you will see that all the info is logged to an XML file that can be rendered in Excel or other apps.

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

Friday, June 22, 2007 3:04 PM by zullu

Thanks Clayton,

I appreciate your patience of going thru my problem.

Yes, I can see that when I click on the "Completed" link I am taken to the Workflow History page. But even though my Workflow has an unconditional step to log the value of a variable and also log a text "Mail Sent", I can't see any entries appearing in this history.

Even though the workflow status says "completed".

Any idea about this.

Thanks again.

zullu.

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

Sunday, June 24, 2007 6:12 PM by zullu

Robert,

Am eagerly waiting for you to respond back.

Please Help!!

I am trying to look for the History log but there seems to be no entries getting logged.

Actually the problem is that the workflow is getting completed, but there is no Email being received by the recepient.

I am getting frustated now.

Can you throw some light on this.

I have viewed your webcast for more than 15 times now to ensure that I have doing the things correctly ( stupid I am :-))

But no worries !!

I need to get this working.

Thanks !!!

zullu.

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

Tuesday, June 26, 2007 1:50 PM by Public Sector DPE Team

Zullu,

I am guessing that you have not stripped off the HTML "Mailto:" tag in the senders email.  Did your look at my posting on how to do this:http://blogs.msdn.com/publicsector/archive/2007/05/08/document-workflow-in-moss-2007-how-to-extract-an-email-address-from-an-email-sent-to-your-document-library-for-workflow.aspx.  As I explain in the blog posting, SharePoint actually puts an HTML tag around the persons email, which makes it your responsibility to strip that HTML BEFORE you can send the email.

~ Robert Shelton

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

Tuesday, July 10, 2007 10:08 AM by zullu

Thanks Robert,

For your precious time. As I told you I have watched ur webcasts several times, so I just wouldn't miss that email stripping stuff.

But the great news is that I have got this email working now!!!

Yes! not exactly sure what I did, but I tried to debug from the scratch, resetting every options and finally made it.

I guess there was something to do with my app pool or the exchange server settings.

But thanks to you, anyways.

Your webcasts have been a really helpful resources to me.

Thanks again,

zullu.

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

Tuesday, July 24, 2007 1:23 PM by Vicky

Hi, I just have a simple workflow setup to send email to a person if got selected from the form in a list.  The workflow runs successfuly and complete, but Email never got sent.  I tested by sending email to myself, but I never receive the email. Do you have any idea?

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

Saturday, September 29, 2007 9:40 PM by Jimmy

This post is very helpful! Thanks so much. I have a quick question. Is there a way to set the e-mail variable such that an e-mail from the workflow is sent to the person who is currently logged in.

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

Tuesday, October 30, 2007 4:00 PM by WL

Hello, I'm having trouble getting my workflows to "Complete" using a "wait for" action/query that is set-up to recognize a change to a drop-down field/item in order to send an email notification to a specific user advising of the change (without sending an email everytime the user makes a change to a list record).  Do you know how I can close/stop a workflow using the "wait for" query?  Also, is there any way for a workflow to recognize the first time a change is made to a drop-down field (for example, from No to Yes) and not every time a record is updated (and inadvertenly causes the a query of If X equals Yes then) to result in a positive result and a subsequent email notification?

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

Thursday, January 17, 2008 11:59 AM by jdb_1715

It appears that starting a workflow from an email has stopped working in MOSS SP1. Has anyone else experienced this? Any workaround?

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

Saturday, February 23, 2008 6:42 AM by SFMOSS

In one response I read the suggestion of providing the document rather than a link to it in a WF generated email... That however sidestepped the question of how do you link to the item. I have a List which needs to generate a link to a newly created item (not just the attached file). I have tried all of the URL options to no avail... the path generated does not work.

Any help appreciated.

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

Wednesday, April 30, 2008 12:58 PM by bob

This works if the workflow is triggered manually.  Have you had success firing an email automatically when a new email message is received?

# How to make the title in a document library editable

Monday, June 02, 2008 5:09 AM by Dhanyatha

Hi,

I have a document library. How do I link to title such that I dont have

to display the file name and can click on title to edit the entry.

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

Wednesday, June 04, 2008 3:40 PM by caschaef

Does anyone know if you can send an email to an email enabled document library instead of a person, distribution group, etc. using a workflow?

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

Wednesday, June 25, 2008 1:23 AM by marc

Hi yall. within HP we are trying to implement a new MOSS workflow to facilitate my team's publishing process. never having created workflows or data collection forms before, we charted into new waters cautiously. But, Within two weeks we have a functional concept & I hope our team can start using this soon instead of the 40/50 email per day we each get. SPD ROCKS!!

RESPECT to Stephen Howard !!! http://office.microsoft.com/en-us/sharepointdesigner/HA102564171033.aspx. With his help I have demoed the concept to our team & we plan to begin testing a new solution soon.

I've hit a small snag. Hoping the gurus can point me in the right direction... Our workflow triggers emails at each step with its <BODY> stored in a variable. Doing the look-up's within the initial step allows us to implement new templates in in 1 place & will capture only the initial values. How can we reuse the email templates with all the updated information ?

TRAIL 1

> look-up <MSG> inside <BODY> on the first step

RESULT = initial <MSG> in all emails

> TRAIL 2

<BODY.1><MSG><BODY.2>

RESULT = Success, sort of…

<DUE DATE><STATUS> look-ups in <BODY> not updated :(

As we update the email templates it would be imposable to replace the HTML in every send email step & re-do the look-ups. I guess im trying to store the look-up inside my template NOT the value each look-up generates so that I can reuse them with all the current info. Can this be done or should be going a diffrent route ?

Please link me back

m  | a | r | c | . | b | u | l | b | u | l | I | a | n | @ | h | p | . | c | o | m

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker