【问题标题】:how to convert the html tags and get a message in string如何转换html标签并在字符串中获取消息
【发布时间】:2011-02-25 10:14:49
【问题描述】:

如何在邮件功能中将html标签转换为msg bodg。

我有

  公司名称:BPL

  行业类型:  

我得到的字符串为

数据表 dt=new datatable();

string msg=dt.rows[i]["Message"].tostring();

我需要将此 html 标记转换为确切的消息;

           if (boolcheck)
            {
                msg.Body = ????????? wat to use over here.... how to remove the html tags and get the exact message

            }

请帮忙????????????/

【问题讨论】:

  • 请更具体。向我们展示一个示例 msg 以及它在 msg.Body 中的确切外观
  • 公司名称:

    我需要删除这个

    标签,即 html 标签,并且只显示像 compnayname .. 这样的消息

标签: c# asp.net html email


【解决方案1】:

这应该对你有帮助。

public string Strip(string text)
{
    return Regex.Replace(text, @”<(.|\n)*?>”, string.Empty);
}

要删除特定标签,试试这个http://urenjoy.blogspot.com/2008/10/remove-html-tags-from-string.html

【讨论】:

    【解决方案2】:

    使用正则表达式

    Regex.Replace(msg, "<.*?>", string.Empty);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-07
      • 1970-01-01
      • 2012-01-19
      • 2011-08-21
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 2013-08-14
      相关资源
      最近更新 更多