Hello There,
I was given the task to do some automatic content changes within the outlook signature files…
For the main part, all is working fine as they are just simple replacements. But in the .htm file, I do have a spot that gets generated by Outlook like this:
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span
style='mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri'>Max
Mustermann<o:p></o:p></span></b></p>
My task is to replace the “Max Mustermann” in there with whatever Name I am given.
Also, this is:
- The only place where my code doesn’t work
- The only Occurrence where Outlook decides to put a line-break within the name
I do have tried many ways but have not found any solution. Some of my tries are in the following code snippet:
#read file
$text = Get-Content -Path $FilePath
#vars
$Name = Read-Host -Prompt "Enter Name"
...
#refining $Name
$NameArray = $Name.Split(' ')
#replacement stuff
$text = $text -replace '(?s)Max(?<space>.*?)Mustermann', ($NameArray[0] + '${space}' + $NameArray[1])
#Having to keep the spacer (like '%20' instead of ' ')
$text = $text.replace("Max
Mustermann", $Name)
#$text = $text -replace "Max`nMustermann", ($NameArray[0] + '`n' + $NameArray[1])
... #other replacements
Out-File -FilePath .\Result\default.htm -InputObject $text
I have also tried many variations of the above code as well as simply just to find that piece in the file.
And, I am using Powershell 5.1 (which is natively included in windows)
I hope, there is some way to fix this problem but anyways
Thanks for your help and your brain cells ![]()