<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>SendEmail when check box changes state using script.js</title><link>https://www.infopathdev.com:443/forums/thread/104071.aspx</link><pubDate>Mon, 21 Sep 2015 16:22:06 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:104071</guid><dc:creator>diskovered</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/104071.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=104071</wfw:commentRss><description>I&amp;#39;m trying to modify this function and was hoping to get some help from the community. How do add a code so when a field state changes, in this case, if a field is checked/selected, it would send me an email alert via my smarthost / smtp server. I tried using Rules and having my email address as the Data Connection but that didn&amp;#39;t work as there is no Outlook installed (installing is not an option)


&lt;br /&gt;&lt;br /&gt;


&lt;code&gt;
//=======&lt;br /&gt;
// The following function handler is created by Microsoft Office InfoPath.&lt;br /&gt;
// Do not modify the name of the function, or the name and number of arguments.&lt;br /&gt;
//=======&lt;br /&gt;
function SaveSubmit::OnClick(eventObj)&lt;br /&gt;
{&lt;br /&gt;
	if(!CheckCommentsLength())&lt;br /&gt;
	{&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;&lt;br /&gt;
	
	if (! FieldName()) { &lt;br /&gt;	
		return;&lt;br /&gt;
	}&lt;br /&gt;&lt;br /&gt;
		
	if (SaveForm()) { // if worked to save then&lt;br /&gt;
		var formid = XDocument.DOM.selectSingleNode&lt;br /&gt;&lt;br /&gt;

(g_datarootelement + &amp;quot;/my:FieldName1&amp;quot;).text;&lt;br /&gt;
		var version = XDocument.DOM.selectSingleNode&lt;br /&gt;&lt;br /&gt;

(g_datarootelement + &amp;quot;/my:FieldName2&amp;quot;).text;&lt;br /&gt;
		var usertoken = XDocument.DOM.selectSingleNode&lt;br /&gt;&lt;br /&gt;

(g_datarootelement + &amp;quot;/my:FieldName3&amp;quot;).text;&lt;br /&gt;&lt;br /&gt;

		UnlockForm(form1, form2, form3);&lt;br /&gt;
	}	&lt;br /&gt;&lt;br /&gt;

	
	ForceClose();&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;</description></item></channel></rss>