根据代码

时间:2016-03-15 17:18:35

标签: powershell hyperlink

我试图通过powershell脚本超链接显示在我的收件箱中的数字。但是超链接显示为代码本身而不是所需的可点击链接。

$b = $b + @{Label='ID';Expression={'a href="http://fire.sync.net/show_bug.cgi?id="$Bug_Id">$(Bug_Id)</a>'}}
Add-Type -AssemblyName System.Web
[System.Web.HttpUtility]::HtmlDecode($b)

在我的邮箱中显示为

http://fire.sync.net/show_bug.cgi?id'+'='+'Bug_id'>211

预期 - 211可点击并指向指定的网址。

超链接部分的代码 -

$a = "<style>"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: gray;border-collapse: collapse; margin: 0 auto; width: 100%;}"
$a = $a + "TH{border-width: 1px; padding: 7px; border-style: solid;}"
$a = $a + "TD{border-width: 0px;}"
$b = $b + @{Label='ID';Expression={"<a href='http://fire.sync.net/show_bug.cgi?id=$Bug_Id'>$Bug_Id</a>"}}


[System.Web.HttpUtility]::HtmlDecode($b)
$a = $a + "</style>"


$body = $DataSet.Tables[0] | Select $b,Status,Summary,Deadline | convertto-html -head $a |  out-string;

请帮忙。

2 个答案:

答案 0 :(得分:0)

请改为尝试:

Expression={ "<a href='http://fire.sync.net/show_bug.cgi?id=$Bug_Id'>$Bug_Id</a>" }

你也错过了我在我的例子中包含的开场<

答案 1 :(得分:0)

尝试splatting你的HTML。您还可以通过添加<xsl:template match="*[contains(@class, ' topic/topic ')]" mode="in-this-section-chapter-list"> <xsl:with-param name="value-number"> <xsl:apply-templates select="key('map-id', @id)[1]" mode="topicTitleNumber"/> </xsl:with-param> <xsl:if test="$value-number!=''"> <fo:block margin-left="6em"> <fo:block> <xsl:call-template name="insertVariable"> <xsl:with-param name="theVariableID" select="'Chapter with number'"/> <xsl:with-param name="theParameters"> <number> <fo:inline> <xsl:apply-templates select="key('map-id', @id)[1]" mode="topicTitleNumber"/> </fo:inline> </number> </xsl:with-param> </xsl:call-template> </fo:block> </fo:block> </xsl:if> </xsl:template> 开关,将样式表作为转换为HTML的一部分。

-Head

This article对发送格式丰富的HTML电子邮件有很好的解释。