Sharepoint task list doesn't send email on item creation

19,740

Unfortunately, our mail servers were blocking the emails for some reason. I wasted a good 2 1/2 days searching around for this problem...and it turns out our IT department didn't have their sh*t together.

Thanks everyone.

Share:
19,740
Eric C
Author by

Eric C

Senior Software Developer mid-town manhattan Likes: C#, ASP.NET 4, MVC 3, Razor View Engine, RESTful web services, XML/XSLT, UI/UX Design & Integration Web: HTML 5, CSS 3, JavaScript, jQuery, Canvas / SVG Mobile: PhoneGap, Sencha Touch, jqTouch SharePoint 2010/07, InfoPath 2010/07, SharePoint / .NET Workflow Foundation, Custom Web Parts, Custom Theme / Design, SharePoint Designer

Updated on June 04, 2022

Comments

  • Eric C
    Eric C almost 2 years

    I've created a custom workflow which creates a task item when the workflow is kicked off. alt text http://img19.imageshack.us/img19/2862/screenshot310200942100p.png

    I've also created a few custom content types for the document library and task list.

    For the document library: First, I add a document library and configure it to allow custom content types. Then I add my content type, which is based off the document content type. After, I add a workflow under workflow settings. Here, I select my custom workflow, give it a name and tell sharepoint to create a New task list to store the tasks in.

    For the task list: Now that I have a sharepoint created task list, I go there and allow custom content types and make sure "Send e-mail when ownership is assigned?" is set to Yes. Then I add my two custom content types which are both based off a workflow task content type. Thats all I should do.

    When I start my workflow, it does add the approval task (I'm using a CreateTaskWithContentType activity which is named createApprovalTask), but no email is sent out for the created task.

    The code I'm using in the createApprovalTask activity is:

    // make a new GUID for this task
    createApprovalTask_TaskId = Guid.NewGuid();
    // set simple properties of task
    createApprovalTask.TaskProperties.AssignedTo = "a valid domain\user";
    createApprovalTask.TaskProperties.Title = "Review Contract: " + approvalWorkflowActivated_WorkflowProperties.Item.DisplayName;
    createApprovalTask.TaskProperties.SendEmailNotification = true;
    

    If I create a document library and use one of Sharepoint's built-in workflows (Approval for example), and tell it to create a task list for it, when an item is added to that list, it sends out the email correctly. So, the setting for the outgoing mail server are correct, as we're receiving other emails just fine.

    I'm using a SendEmail activity right after the createApprovalTask activity to send an email back to the submitter telling them we've received their approval request. The code for that is something similar to:

    sendApprovalRecievedEmail.Body = emailBody;
    sendApprovalRecievedEmail.Subject = emailSubject;
    sendApprovalRecievedEmail.To = emailTo;
    sendApprovalRecievedEmail.From = emailFrom;
    

    This works, so the submitter receives their custom email, but the task owner never receives the task item email.