Created
May 21, 2013 06:27
-
-
Save lukencode/5617855 to your computer and use it in GitHub Desktop.
Embedded tempate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Adds template to email from embedded resource | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="path">Path the the embedded resource eg [YourAssembly].[YourResourceFolder].[YourFilename.txt]</param> | |
/// <param name="model">Model for the template</param> | |
/// <param name="isHtml">True if Body is HTML, false for plain text (Optional)</param> | |
/// <param name="assembly">The assembly your resource is in. Defaults to calling assembly.</param> | |
/// <returns></returns> | |
public Email UsingTemplateFromEmbedded<T>(string path, T model, bool isHtml = true, Assembly assembly = null) | |
{ | |
CheckRenderer(); | |
assembly = assembly ?? Assembly.GetCallingAssembly(); | |
var template = EmbeddedResourceHelper.GetResourceAsString(assembly, path); | |
var result = _renderer.Parse(template, model, isHtml); | |
Message.Body = result; | |
Message.IsBodyHtml = isHtml; | |
return this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment