asp.net - How can I include the contents of a .txt file into a C# application and read the contents in? -


i have code sends email message users on registration:

await usermanager.sendemailasync(2, "confirm account", "large amount of text here"); 

the text want include few hundred lines of html me insert directly c# code. had suggestion create .txt file, embed in assembly, , read assembly.getmanifestresourcestream.

can give me suggestions on how go doing this?

the text want include few hundred lines of html me insert directly c# code. had suggestion create .txt file, embed in assembly, , read assembly.getmanifestresourcestream.

well, can try follow outlined steps. add new emailbody.html file project , set build action embedded resource. can read contents:

var assembly = typeof(someclassfromtheassemblythatcontainsthehtml).assembly; using (var stream = assembly.getmanifestresourcestream("yourprojectname.emailbody.html")) using (var reader = new streamreader(stream)) {     string body = reader.readtoend();     await usermanager.sendemailasync(2, "confirm account", body); } 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -