Infopath VSTA managed code – How to trigger email notifications through a submit button

Infopath VSTA managed code – How to trigger email notifications through a submit button
 
Example code….
 
        public void btnEmailNotification_Clicked(object sender, ClickedEventArgs e)
        {
            XPathNavigator mynav = this.MainDataSource.CreateNavigator();
            string txtEmailAddress;
            string txtForename;
            string txtSurname;
            txtEmailAddress = mynav.SelectSingleNode(“”/my:myFields/my:txtEmailAddress””, NamespaceManager).Value;
            txtForename = mynav.SelectSingleNode(“”/my:myFields/my:Forename””, NamespaceManager).Value;
            txtSurname = mynav.SelectSingleNode(“”/my:myFields/my:Surname””, NamespaceManager).Value;
            MailAddress from = new MailAddress(“”rob.ashcroft@cheshire.gov.uk””);
            MailAddress to = new MailAddress(txtEmailAddress);
            MailMessage msgmail = new MailMessage(from, to);
            msgmail.IsBodyHtml = true;
            msgmail.Body = “”Thank you for submitting a Community Services Transport Request Form

Your form has now been processed

Transport Co-ordination””;
            msgmail.Subject = “”Your Community Services Transport Request Form””;
            SmtpClient client = new SmtpClient(“”mailext.cccnet””);
            client.Send(msgmail);
        }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s