简体   繁体   中英

Change email subject

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 = x@y.com;
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?

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 ie "/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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM