Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active April 20, 2017 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/dede268fca125beca494e2de2adbeebc to your computer and use it in GitHub Desktop.
Save bjoerntx/dede268fca125beca494e2de2adbeebc to your computer and use it in GitHub Desktop.
// create a new Order
Order order = new Order()
{
Customer = new Customer() { Name = "Peter Customer" }
};
// create a new ProductBlock
ProductBlock block = new ProductBlock();
block.Products = new List<Product>()
{
new Product() { Name = "Product 1", Price = 200 },
new Product() { Name = "Product 2", Price = 400 },
new Product() { Name = "Product 3", Price = 800 }
};
// add the ProductBlock to the ObservableCollection
order.ProductBlocks.Add(block);
// create a second ProductBlock
ProductBlock block2 = new ProductBlock();
block2.Products = new List<Product>()
{
new Product() { Name = "Product 4", Price = 231 },
new Product() { Name = "Product 5", Price = 32424 },
new Product() { Name = "Product 6", Price = 33 },
new Product() { Name = "Product 7", Price = 332 },
};
order.ProductBlocks.Add(block2);
// merge the template with the business object
using (MailMerge mailMerge = new MailMerge())
{
mailMerge.TextComponent = textControl1;
mailMerge.MergeObject(order);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment