I am trying to use an Active X object to send certain fields for my form to a particular email group and I can get the email to go, but am having trouble getting the info from the fields into the message body.
Here is the code for the email.
//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of arguments.
//=======
function CTRL11_9::OnClick(eventObj)
{
// Create a new message and fill all its fields
var iMsg = new ActiveXObject("CDO.Message");
iMsg.To = "
[email protected]";
iMsg.From = "
[email protected]";
iMsg.Subject = "Termination Form";
iMsg.TextBody = "Department : \'" + XDocument.DOM.selectSingleNode("/dfs:datafields/dfs:Termination/@Department").text;
// Set SMTP server
iMsg.Configuration.Fields
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "crmcexchm1.crmc.com"
// Use the SMTP over the netowrk for sending method
iMsg.Configuration.Fields
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2;
// Make persistent
iMsg.Configuration.Fields.Update();
// Send the message
iMsg.Send();
}
I have secondary namespaces in the form and verfied the xpath using expression boxes. The object required error keeps showing up.
All of the fields I am trying to send are in the main dom.
Here is the code for the namespaces.
// The following line is created by Microsoft Office InfoPath to define the prefixes
// for all the known namespaces in the main XML data file.
// Any modification to the form files made outside of InfoPath
// will not be automatically updated.
//<namespacesDefinition>
XDocument.GetDOM("Employee Info").setProperty("SelectionNamespaces" , 'xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"')
XDocument.GetDOM("Department List").setProperty("SelectionNamespaces" , 'xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"')
XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-02-20T16:59:23" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"');
//</namespacesDefinition>
I have researched this over and over have tried several ideas off of this forum and others as well. Any help woul be greatly appreciated.
Thanks