Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一些以 HTML 格式编写的电子邮件模板,我需要在后面的代码中使用它来传递一些值。
你知道在后面的代码中我想将它传递给 Message Body 属性,所以它应该是一行,
是否有任何简单的原因,正则表达式替换或任何其他避免手动格式化的技巧,
我不确定我是否完全理解你想要做什么。但是,如果您想将某种常量多行文本插入到变量中,则可以使用@关键字来完成。
@
例如,这将编译得很好:
mailMessage.Body = @"<html> <head> <title>Test</title> </head> <body> <div> .... "; mailMessage.Subject = ....
当然,应该使用常量,但这只是一个示例。