May 052010

SharePoint outgoing mail to SharePoint incoming mail library

I was trying to submit an infopath form through infopath form services (browser) with an e-mail to an incoming mail library on a SharePoint in another domain. I noticed that the mail was appearing in the drop folder, and was beging deleted after a minute (TimerService) but it didn't get added to my library.

When i tried to send exactly the same mail from Outlook it worked like a charm. This problem gave me a couple of hours headache and then i found this Microsoft kb saying basicly it's not supported to prevent loops. So a mail coming from workflow / alert / form services is not allowed in incoming mails for a library.

Now the good news is that there is a solution to this which i found here .

1. copy Smtpreg.vbs into the c:\inetpub\AdminScripts - smtpreg is available to download from MS. (google it)
2. create a vbs file from the script below and copy it to the AdminScripts folder (I named mine wss)
3. run the following commands to register the script
cd c:\inetpub\adminscripts
cscript smtpreg.vbs /add 1 OnArrival DeleteMsg CDO.SS_SMTPOnArrivalSink "mail from=*"
cscript smtpreg.vbs /setprop 1 OnArrival DeleteMsg Sink ScriptName "c:\Inetpub\AdminScripts\wss.vbs"
4. This will now catch all mail on arrival and remove the offending header.
So after hours of searching i finally found a "hack" to succesfully get Infopath form service mails to get picked up by the SPTimerService and saved in my incoming mail library.
Hope this helps someone out there!


Published: 5/5/2010  3:22 PM | 0  Comments | 0  Links to this post

Apr 212010

Infopath form server - passing url parameter to a infopath form


I wanted to load a new infopath form into a Xmlformview webpart in Sharepoint, but at the same time pass a url queryparameter to the infopath form.
At first you might think that this can't be done without code behind on the infopath form but I found an easy way to do this based on an article (Steven Van De Craen) of a collegue of mine.
The methods are quit simple

  1. Make sure u get a url parameter in the publishing page by clicking a link (ex http://moss/pages/createdoc.aspx?parameter=23
  2. Create a new custom SharePoint webpart that extends the Microsoft.Office.InfoPath.Server.Controls.XmlFormView class.
  3. Add an eventhandler in the onInit of the webpart for this.initialise
  4. In the handler add code to change the XML nodes in the infopath doc (pass parameter to a hidden field or something).

public class XmlFormViewExtender : Microsoft.Office.InfoPath.Server.Controls.XmlFormView
private bool _error = false;
private string _xpath = null;
private string _param = null;
[System.ComponentModel.Category("My Property Group")]
[WebDescription("parameter Property")]
public string Param
if (_param == null)
{_param = "par";
return _param;
set { _param = value; }
[System.ComponentModel.Category("My Property Group")]
[WebDescription("XPath Property")]
public string XPath
if (_xpath == null)
_xpath = "/my:form/my:param";
return _xpath;
set { _xpath = value; }
protected override void OnInit(EventArgs e)
this.Initialize += new EventHandler(XmlFormViewExtender_Initialize);
protected void XmlFormViewExtender_Initialize(object sender, Microsoft.Office.InfoPath.Server.Controls.InitializeEventArgs e)
if (XmlForm != null)
string value = this.Page.Request.QueryString[Param];
XPathNavigator _xNavMain = this.XmlForm.MainDataSource.CreateNavigator();
XPathNavigator result = _xNavMain.SelectSingleNode(XPath, this.XmlForm.NamespaceManager);
I've also created 2 properties (Param, XPath) for the webpart that hold the name of the parameter it should get (querystring) and the Xpath where to place the value of this param.
So the result of this webpart is that the value of the url parameter par will be filled into the XML of the infopath form in "/my:form/my:param" and will show this data when rendering the form.


Hope this helps someone out!

Published: 4/21/2010  3:20 PM | 0  Comments | 0  Links to this post