In the end I built a workflow in sharepoint designer to move the forms and triggered it with the code below (A Console App)
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.SharePoint;
using System.Text;
using Microsoft.SharePoint.Workflow;
using System.Web.Mail;
namespace TriggerWorkflowManually
{
class Program
{
static void Main(string[] args)
{
if (args.Length != 4)
{
Console.WriteLine("TriggerWorkflowManually requires the following Parameters");
Console.WriteLine("Site URL: The URL of the site you want to use");
Console.WriteLine("Library Name: The name of the library containing no escape characters");
Console.WriteLine("WorkFlow Name: The name of the assosiated workflow you want to trigger");
Console.WriteLine("Email: The email you want the report sent to");
return;
}
else
{
string siteURL = args[0];
string libraryName = args[1];
string workflow = args[2];
string email = args[3];
SPSite site = new SPSite(siteURL);
// Open Site and find lists
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPList list = web.Lists[libraryName];
SPFolder folder = web.GetFolder(libraryName);
SPFileCollection files = folder.Files;
SPListItemCollection collection = list.Items;
StringBuilder sb = new StringBuilder();
Dictionary<string, string> errorDictionary = new Dictionary<string, string>();
Dictionary<string, string> successDictionary = new Dictionary<string, string>();
// Loop through the sharepoint list
foreach (SPListItem item in collection)
{
Console.WriteLine("Triggering Item: " + item["Name"]);
SPWorkflowAssociation associationTemplate = list.WorkflowAssociations.GetAssociationByName(workflow, new System.Globalization.CultureInfo("en-GB"));
try
{
site.WorkflowManager.StartWorkflow(item, associationTemplate, associationTemplate.AssociationData, true);
successDictionary.Add(item["Name"].ToString(), item["GUID"].ToString());
}
catch (Exception e)
{
Console.WriteLine("Problem encountered While Triggering workflow for item:" + item["Name"]);
errorDictionary.Add(item["Name"].ToString(), e.ToString());
Console.WriteLine(e);
}
}
// Loop through dictionary and mail a report
foreach (KeyValuePair<string, string> pair in errorDictionary)
{
sb.Append('"' + pair.Key + '"' + "," + '"' + pair.Value + '"' + ';');
}
// Report the number of rows updated and number of errors encountered
Console.WriteLine("Total Rows Updated: " + successDictionary.Count);
Console.WriteLine("Total Errors Encountered: " + errorDictionary.Count);
// Send the user a mail
MailMessage objEmail = new MailMessage();
objEmail.To = email;
objEmail.From = email;
objEmail.Subject = "This is your workflow report";
objEmail.Body = "Total Rows Updated: " + successDictionary.Count + "\n" + "Total Errors Encountered: " + errorDictionary.Count + "\n" + "Errors: " + sb.ToString();
objEmail.Priority = MailPriority.High;
SmtpMail.SmtpServer = "mail.servername.com";
SmtpMail.Send(objEmail);
}
}
}
}