How can I adding a Hyperlink to my Mailadr

  Kiến thức lập trình

I have created a script to create an email signature via Word, the problem is that I would like to provide the mail address with a hyperlink with “mailto:$email”, but I don’t know how to do that.
I have tried a lot of possibilities, but nothing has worked. Can someone please help me.

The code where I like to insert it:

# change all the placeholde in our Word template

$MSWord.Documents.Open("$LocalSignaturePath$newSignatureName.docx", $false)

$FindText = "Name"
$ReplaceText = $titel.ToString() + " " + $vorname.ToString() + " " + $nachname.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,  $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll)

$FindText = "EMAIL"
$ReplaceText = $email.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,  $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll)

$FindText = "Description"
$ReplaceText = $job.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,  $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll)

$FindText = "mobile1"
$ReplaceText = $mobile.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,  $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll)

$FindText = "OFFICEPHONE1"
$ReplaceText = $phone.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,  $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll)

$FindText = "CITY"
$ReplaceText = $CITY.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,  $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll)

$FindText = "POSTALCODE"
$ReplaceText = $POSTALCODE.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,  $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll)

$FindText = "STREETADDRESS"
$ReplaceText = $STREETADDRESS.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,  $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll)

$FindText = "COMPANY"
$ReplaceText = $COMPANY.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,  $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll)


# Save Signature files in multiple extensions (needed for Outlook)
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatHTML");
$path = "$LocalSignaturePath$newSignatureName.htm"
$MSWord.ActiveDocument.SaveAs([ref]$path, [ref]$saveFormat)

$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatRTF");
$path = "$LocalSignaturePath$newSignatureName.rtf"
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)

$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatText");
$path = "$LocalSignaturePath$newSignatureName.txt"
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat)

$MSWord.ActiveDocument.Close()
$MSWord.Quit()

I have tried the solution approach from this website Powershell script that finds and changes hyperlinks in word saves doc and creates a new copy as PDF and this website https://forums.powershell.org/t/adding-hyperlinks-to-word-via-powershell/624, but without success

New contributor

Daniel L. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT