473,408 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Text merge

I have signature templates containing variable parts like user name between
<< and >signs, like

Best regards,
<<User.FirstName><<User.FirstName>>
MyCompany
Baker street 123
Phone: <<User.Phone>>
How to replace fields between << and > marks with current values in
runtime ?
Is it possible to evaluate expressions also if << >contains expressions ?

Andrus.

Jun 27 '08 #1
2 1966
Andrus wrote:
I have signature templates containing variable parts like user name
between << and >signs, like

Best regards,
<<User.FirstName><<User.FirstName>>
MyCompany
Baker street 123
Phone: <<User.Phone>>
How to replace fields between << and > marks with current values in
runtime ?
Create a method that returns the value when you send it the key of a
variable:

private static string GetValue(string key) {
switch (key) {
case "User.FirstName": return "Göran";
case "User.LastName": return "Andersson";
case "User.Phone": return "012-34 56 78";
default: throw new ArgumentOutOfRangeException("key", key, "Unknown
key.");
}
}

Then you can use that with a regular expression that replaces the variables:

string message = Regex.Replace(template, "<<([^>]+)>>", delegate(Match
m) { return GetValue(m.Groups[1].Value); });
Is it possible to evaluate expressions also if << >contains expressions ?
Everything is possible, but that is quite a bit trickier. What kind of
expressions were you thinking of?

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #2
Göran,

thank you very much.
>Is it possible to evaluate expressions also if << >contains expressions
?

Everything is possible, but that is quite a bit trickier. What kind of
expressions were you thinking of?
Expression are simple expressions e.q if contact person name is not
specified, use copmany name, otherwize use contact person name like

<< Iif(Customer.LastName!=null, "Dear " + Customer.LastName,
Customer.CompanyName) >>

They should hect
Andrus.

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Guillaume Lahitette | last post by:
Hello everyone, I am looking for a lightweight Java Applet to diff and merge two text files. The functionality would be a subset of what WinMerge (http://winmerge.sourceforge.net) offers: -...
4
by: matt tagliaferri | last post by:
We have remote users running MSDE entering information into a database. To send the data back to the home office, we've written some routines that export the data into SQL Scripts in text files: ...
0
by: Steve | last post by:
My application uses transfertext to create text files that are FTPed to a website and are processed by a webstore. The text files can be for one of three purposes: Add one or more items to the...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
0
by: Ron Andersen | last post by:
I have C# custom actions and merge modules created in Visual Studio to install some components of the application I am working on. The merge modules are used with an Install Shield 9 project. ...
14
by: Joe | last post by:
Hello All: I am trying to dynamically populate a web page with literal content and controls (textboxes and checkboxes (and eventually two buttons - the buttons do not appear in the code yet). I...
6
by: Lance Geeck | last post by:
I have a simple form where I am using a dataset called Client. On the data entry screen, there are name, address, city state and zip. I have the fields bound to the dataset field. (Properties...
11
by: MLH | last post by:
If I run MsgBox "Wow!" and I see text in the title bar - where is that text string setting coming from? Do I have access to change it?
1
by: mr k | last post by:
Hi, I wanted to use mail merge with forms but Text form fields are not retained during mail merge in Word, I got the code from Microsoft but it doesn't remember the text form field options such as...
2
by: JeffN825 | last post by:
Hello, Thank you in advance for any assistance. I am trying to set up a mail merge from VB6/VBA code with Word 2000 using an ODBC data source (SQL 2000). I have successfully gotten the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.