In order to send an attachment within a workflow I had to write my own method since the out-of-the-box SendEmail activity doesn't support attachments. While doing this I had to figure out how to attach an InfoPath form to the e-mail. Using the code below I was able to accomplish this task. Not very obvious at first but after diving into what is actually going on it makes perfect sense.
Stream formStream = spItem.File.OpenBinaryStream();
System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/xml");
Attachment attachment = new Attachment(formStream, ct);
attachment.Name = spItem.File.Name;
mailMessage.Attachments.Add(attachment);
Hope this helps someone who is trying to do the same thing. There is an activity out on Codeplex for this but that only applies to SharePoint designer workflows. If I had time and there was a need for it, I would create a VS Workflow activity for this.
Showing posts with label Workflow. Show all posts
Showing posts with label Workflow. Show all posts
Wednesday, June 18, 2008
Subscribe to:
Posts (Atom)