Question : Mail-Merge Methods C#

Hi All,

I am creating a mailing list function for a client that will enable them to write a message and then include format items such as [Name] and [Email] which will then be replaced with data like your typical mail-merge similar to String.Format() method.  But rather than being limited to specifying format items as so {0}, {1} etc.. I would like to use format items that would be more specific to the user such as [Name], [Email].

Could anyone suggest an effective way to achieve this?

Many thanks,

Rit

Answer : Mail-Merge Methods C#

Oooooooh I get it now. Okay, try this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
DataTable dt = GetUserTable();
if (dt.Rows.Count > 0)
{
     foreach (DataRow row in dt.Rows)
     {
         string strTemplate;
     
         strTemplate = "

Hi [User_Name]

" + "

Check out our new site at " + "[Site_Address]
" + "and then enter your email address and access id which is [Site_ID].

" + "

We look forward to keeping in touch with you through our website.

" + "

Kind Regards,
" + "[Customer_Name]

"; strTemplate = strTemplate.Replace("[User_Name]", row["UserName"].ToString()); strTemplate = strTemplate.Replace("[Site_Address]", row["SiteAddress"].ToString()); strTemplate = strTemplate.Replace("[Site_ID]", row["SiteID"].ToString()); strTemplate = strTemplate.Replace("[Customer_Name]", row["CustomerName"].ToString()); } }
Random Solutions  
 
programming4us programming4us