Paul's profilePaul Galvin's SharePoint...BlogListsSkyDrive Tools Help

Blog


    October 16

    Programmatically Extracting Attachments From InfoPath Forms (Including Their Names!)

    I have an expense entry solution for a client that leverages InfoPath and workflow.  At one point during the approval process, I need to generate an email that has all of that good InfoPath data as well as the attachments themselves so that (sigh) someone can take that data and manually re-key it into an Oracle database application.

    It’s not very difficult to get at or parse the InfoPath form.  I didn’t know how to handle the attachments, however.  After an hour or two of poking around the Internets (an eternity!) I found this article: http://support.microsoft.com/kb/892730

    It provide some handy code to extract the attachment from a node in the form.  (You still need to find the node and all that, but that’s just XML parsing).

    I know that the attachment is base64-encoded and I originally went down the path of just extracting the the base64 data, decoding it and saving it.  However, I quickly realized I didn’t know how to get the file name itself until I found the aforementioned article.

    I had actually found that quite early, but I was put off by its split personality. On the one hand, the article *says* it’s good for InfoPath 2007.  Yet, the code and instructions are all about Visual Studio 2003 and references to InfoPath 2003.

    Bottom line, the code that article provided is working well for me (so far).  I can get my InfoPath form, I can parse it, I can find and decode the attachment and I know its name.  What more can one ask of one’s life?

    </end>

    Subscribe to my blog.

    Follow me on Twitter at http://www.twitter.com/pagalvin

    Technorati Tags: ,,

    If you’re worried that your SharePoint environment may be a tad unhealthy, let me help you fix that with a health check.

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.
    Paul Galvin has turned off comments on this page.

    Trackbacks

    The trackback URL for this entry is:
    http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!4794.trak
    Weblogs that reference this entry
    • None