Reputation: 6050
I am using InfoPath 2007
I have some code written in the form that will put a form into an e-mail. I would like to alter the subject of that e-mail so that I can display a fixed piece of text as well as the results from the data in one of the form fields;
var objEmail;
objEmail = Application.ActiveWindow.MailEnvelope;
objEmail.To = [email protected];
objEmail.Subject = "extras request";
objEmail.Visible = true;
I want to alter the line
objEmail.Subject = "extras request";
to include display the results from the data in the form field labNO but I am not sure how ?
Upvotes: 0
Views: 356
Reputation: 1687
var navigator = MainDataSource.CreateNavigator();
var labNO = navigator.SelectSingleNode(xpath, this.NamespaceManager).Value;
objEmail.Subject = string.Format("extras request {0}", labNO);
The variable 'xpath' is a string which points to the labNO field i.e. "/my:myFields/my:labNO". You can copy it by right-click'ing the field - Copy XPath.
If the labNO field is within an external DataSource, you'd use this instead:
var navigator = DataSources["DataSourceName"].CreateNavigator();
Upvotes: 1