<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Microserf &#187; SharePoint 2003</title>
	<atom:link href="http://microserf.wordpress.com/category/sharepoint-2003/feed/" rel="self" type="application/rss+xml" />
	<link>http://microserf.wordpress.com</link>
	<description>A humble student of the art of software development</description>
	<lastBuildDate>Mon, 14 Dec 2009 16:22:25 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='microserf.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/aa8c6dcecdda70a9cb0f44c69df02492?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Microserf &#187; SharePoint 2003</title>
		<link>http://microserf.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://microserf.wordpress.com/osd.xml" title="Microserf" />
		<item>
		<title>Sending an InfoPath 2003 form to people who don&#8217;t have the client</title>
		<link>http://microserf.wordpress.com/2007/02/07/sending-an-infopath-2003-form-to-people-who-dont-have-the-client/</link>
		<comments>http://microserf.wordpress.com/2007/02/07/sending-an-infopath-2003-form-to-people-who-dont-have-the-client/#comments</comments>
		<pubDate>Wed, 07 Feb 2007 09:02:28 +0000</pubDate>
		<dc:creator>microserf</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[InfoPath 2003]]></category>
		<category><![CDATA[SharePoint 2003]]></category>
		<category><![CDATA[Visual Studio 2005]]></category>

		<guid isPermaLink="false">http://microserf.wordpress.com/2007/02/07/sending-an-infopath-2003-form-to-people-who-dont-have-the-client/</guid>
		<description><![CDATA[I needed to send the completed (ie approved) form, read-only, to the company who took care of the orders made in an InfoPath 2003 form. The form is stored in a SharePoint forms library, but the receiving company didn&#8217;t have access to this SharePoint site. 2007 would be sweet, but I can&#8217;t use that. Hmmm&#8230; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=microserf.wordpress.com&blog=488283&post=22&subd=microserf&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I needed to send the completed (ie approved) form, read-only, to the company who took care of the orders made in an InfoPath 2003 form. The form is stored in a SharePoint forms library, but the receiving company didn&#8217;t have access to this SharePoint site. 2007 would be sweet, but I can&#8217;t use that. Hmmm&#8230; how to do?</p>
<p>I created a web service, which the form, once approved, sent an email through (all stages in the workflow <strong>before</strong> approval used the ordinary data connection to the SharePoint forms library).</p>
<p>The web service receives the xml document from InfoPath, via the normal web service data connection available. The web service extracts the filename (stored as a secondary data source inside the form) and makes an html document out of the xml and xsl combined, which then can be viewed on any computer with an internet browser.</p>
<p>There&#8217;s one big-ass downside with this though. The xsl file has to be extracted from the infopath form and then edited a little to remove not-supported functions and so on, or else you&#8217;ll se some nasty error messages when opening the form in the browser. So if the form has undergone some major changes, you need to re-extract the xsl-file and put it somewhere where the web service can access it, which in my case is in the web service root directory. </p>
<p>Here&#8217;s the code:</p>
<p>Service.cs</p>
<p><code><br />
[WebMethod]<br />
  public string InfoPathMailer(XmlDocument xmlDoc)<br />
  {<br />
    string filename = GetFileName(xmlDoc);</code><code>Stream stream = new MemoryStream();<br />
    XslCompiledTransform xslTransform = new XslCompiledTransform();<br />
    xslTransform.Load(Server.MapPath("view1.xsl"));<br />
    xslTransform.Transform(xmlDoc, null, stream);<br />
    stream.Position = 0;</code><code>MailSender m = new MailSender("yourmailserver.net", "formsrobot@yourdomain.com", "receiver@company.com", "New End User Request", "Do not reply to this address", filename, stream);<br />
    m.Send();</code><code>    return "";<br />
  }</code><code>private string GetFileName(XmlDocument xmlDoc)<br />
  {<br />
    string infoPathNamespacePrefix = "my";<br />
    string infoPathNamespaceURI = @"http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-11-13T10:36:39";<br />
    XmlNamespaceManager namespaceMngr = new XmlNamespaceManager(xmlDoc.NameTable);<br />
    namespaceMngr.AddNamespace(infoPathNamespacePrefix, infoPathNamespaceURI);</code><code>    XmlNode node = xmlDoc.SelectSingleNode("//my:Filename", namespaceMngr);<br />
    string s = node.InnerText;<br />
    s = s.Replace("xml", "html");<br />
    return s;<br />
  }</code></p>
<p>And here&#8217;s the code for the class MailSender:</p>
<p><code><br />
using System;<br />
using System.Data;<br />
using System.Configuration;<br />
using System.Net;<br />
using System.Net.Mail;<br />
using System.Net.Mime;<br />
using System.IO;</code><code>public class MailSender<br />
{<br />
  MailMessage mail;<br />
  String smtpServer;</code><code>  //Constructor for attachment as stream<br />
  public MailSender(string server, string sender, string receiver, string subject, string body, string filename, Stream stream)<br />
  {<br />
    smtpServer = server;<br />
    mail = new MailMessage(sender, receiver, subject, body);<br />
    Attachment attachment = new Attachment(stream, filename, MediaTypeNames.Text.Html);<br />
    mail.Attachments.Add(attachment);<br />
  }</code><code>public void Send()<br />
  {<br />
    SmtpClient client = new SmtpClient(smtpServer);<br />
    client.Credentials = CredentialCache.DefaultNetworkCredentials;<br />
    client.Send(mail);<br />
  }<br />
}</code></p>
<p>Hopefully this can help someone out there. Good luck!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/microserf.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/microserf.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/microserf.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/microserf.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/microserf.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/microserf.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/microserf.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/microserf.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/microserf.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/microserf.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/microserf.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/microserf.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=microserf.wordpress.com&blog=488283&post=22&subd=microserf&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://microserf.wordpress.com/2007/02/07/sending-an-infopath-2003-form-to-people-who-dont-have-the-client/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bd36ec7f184adfb371f9738da5b53e6d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">microserf</media:title>
		</media:content>
	</item>
		<item>
		<title>Submitting the same InfoPath form multiple times to the same document library in SharePoint</title>
		<link>http://microserf.wordpress.com/2006/11/17/submitting-the-same-infopath-form-multiple-times-to-the-same-document-library-in-sharepoint/</link>
		<comments>http://microserf.wordpress.com/2006/11/17/submitting-the-same-infopath-form-multiple-times-to-the-same-document-library-in-sharepoint/#comments</comments>
		<pubDate>Fri, 17 Nov 2006 15:45:34 +0000</pubDate>
		<dc:creator>microserf</dc:creator>
				<category><![CDATA[InfoPath 2003]]></category>
		<category><![CDATA[SharePoint 2003]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://microserf.wordpress.com/2006/11/17/submitting-the-same-infopath-form-multiple-times-to-the-same-document-library-in-sharepoint/</guid>
		<description><![CDATA[Long title, eh?
My problem was to do just the above, i.e. I had to name the filled out forms with a date and time marker. Because of that, when someone changed the contents of the form, a new one was created with the same name except for the date and time, where as I wanted it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=microserf.wordpress.com&blog=488283&post=16&subd=microserf&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Long title, eh?</p>
<p>My problem was to do just the above, i.e. I had to name the filled out forms with a date and time marker. Because of that, when someone changed the contents of the form, a new one was created with the same name except for the date and time, where as I wanted it to amend the existing file but keep the original name.</p>
<p>I noticed on Google Groups that someone <a href="http://groups.google.com/group/microsoft.public.infopath/browse_thread/thread/bf663d08ba88f859/43cd6208377f2748?lnk=st&amp;q=file+infopath+sharepoint+overwrite&amp;rnum=16#43cd6208377f2748">had a similar problem</a>, but the solution wasn&#8217;t explained in detail (and since I&#8217;m a newbie on InfoPath 2003, it was a little challenge).</p>
<p>Anyway, here&#8217;s how I did it:</p>
<p>1. First I needed to do this in javascript, since the default submitting options didn&#8217;t allow this behaviour. On the <strong>Tools</strong> menu, I chose <strong>Submitting Forms</strong> and then in the Submitting Forms dialog box, clicked <strong>Enable Submit</strong>. In the <strong>Submit</strong> box, I clicked <strong>Submit Using Custom Script. </strong>Also enabled <strong>Open Microsoft Script Editor</strong>, and then I clicked <strong>OK</strong>. The Microsoft Script Editor unveiled to me for the first time, with a new function called <em>function XDocument::OnSubmitRequest(eventObj)</em> in place.</p>
<p>2. I went back to the (Design) template in InfoPath and added a textbox controller at the bottom. I named it <em>filename</em>, set the default value to &#8220;0&#8243; (or whatever), and then went back to the script editor.</p>
<p>3. In the OnSubmitRequest function I added the following code to read the field value from the filename textbox, and if it is zero (which it will be the first time the form is used) a conditional statement that creates a new filename (plus it writes to the new/old file in the sharepoint forms library):</p>
<p><code><br />
var blnSubmitSuccess = false;</code><code></code><code>var strPath = "http://servername/sites/sitename/projectname/formslibraryname/";</code><code> </code><code>var strFilename = XDocument.DOM.selectSingleNode("//my:filename").text;</code><code>if (strFilename == "0")<br />
 {<br />
  strFilename = ...  // Insert code here to generate a filename of your liking<br />
  XDocument.DOM.selectSingleNode("//my:filename").text = strFilename;<br />
 }</code><code>var strUrl = strPath + strFilename;</p>
<p>// Submit the form to the form library.</p>
<p>var objXmlHttp = new ActiveXObject("MSXML2.XMLHTTP.5.0");</p>
<p>try<br />
{<br />
  objXmlHttp.Open("PUT", strUrl, false);<br />
  objXmlHttp.Send(XDocument.DOM.xml);<br />
}<br />
catch (e)<br />
{<br />
  XDocument.UI.Alert("Couldn't create file in SharePoint library due to the following error.\n\n"<br />
  + e.number + " - " + e.description);<br />
}</p>
<p>// Status codes of 200 or 201 indicate that the form<br />
// has been submitted successfully.</p>
<p>if (objXmlHttp.Status == 200 || objXmlHttp.Status == 201)<br />
{<br />
  blnSubmitSuccess = true;<br />
}</p>
<p>return blnSubmitSuccess;</p>
<p></code>That&#8217;s it! Now you can change the form all you like, but it will be saved properly and keep it&#8217;s original name.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/microserf.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/microserf.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/microserf.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/microserf.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/microserf.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/microserf.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/microserf.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/microserf.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/microserf.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/microserf.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/microserf.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/microserf.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=microserf.wordpress.com&blog=488283&post=16&subd=microserf&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://microserf.wordpress.com/2006/11/17/submitting-the-same-infopath-form-multiple-times-to-the-same-document-library-in-sharepoint/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bd36ec7f184adfb371f9738da5b53e6d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">microserf</media:title>
		</media:content>
	</item>
	</channel>
</rss>