Wednesday, June 18, 2008

Programmatically add InfoPath mail attachment (mime types)

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.

4 comments:

Anonymous said...

[url=http://blog.bakililar.az/videosearnold0/]Cucusoft Ultimate DVD + Video Converter Suite 7.13.7.7[/url] [url=http://www.blogportalen.no/blog/?u=videoseamanda8]SpicyTools Video Converter 1.0.0.1[/url]
Easy Video to 3GP Converter 1.3.25 Alldj Video Converter
http://lecturer.elektrounesa.org/?u=videoseanise9 Witcobber Super Video Converter 5.3
[url=http://lecturer.elektrounesa.org/?u=videoseal5]Breeze Standard Edition[/url] [url=http://www.blogsplosion.com/?u=videosealana2]WinAVI Video Converter 9.0.9.0[/url]
3herosoft BlackBerry Video Converter A-Z Video Converter Profession 7.29
http://www.blogportalen.no/blog/?u=videoseabbey9 Video 2 SWF 1.013
Easy DVD Creator 1.6.5
my icq:858499940385

Anonymous said...

It agree, rather amusing opinion

Anonymous said...

What is how to get rid of acne Conglobata? A papule occurs
when a substance emits light for any reason other than those mentioned above
in providing a cure for How To Get Rid Of Acne the better.

electronic signature software said...

Very helpful article ! I was always curious about all these complex algorithms that are being used in these ssl encryptions.