PoshCode Archive  Artifact [1ece6ecdff]

Artifact 1ece6ecdff1a242e0ec6aa3252c82d16a34ce9251c60e10d2833cc209d6a86d9:

  • File HTML-Signature-Function.ps1 — part of check-in [79f62b4095] at 2018-06-10 14:12:50 on branch trunk — Function for creating HTML signatures with conditional markup. (user: _rov3 size: 2328)

# encoding: ascii
# api: powershell
# title: HTML Signature Function
# description: Function for creating HTML signatures with conditional markup.
# version: 0.1
# type: function
# author: _rov3
# license: CC0
# x-poshcode-id: 6312
# x-archived: 2016-04-24T06:47:30
# x-published: 2016-04-21T20:46:00
#
#
Function createSignature {
	param([string]$Template, [string]$Name, [string]$title, [string]$streetAddress, [string]$City, [string]$postalCode, [string]$officePhone, [string]$mobilePhone, [string]$sigpath, [string]$company)

	$Template = Get-Content -Path $Template
	$templateWork = $Template | foreach {
		$_ -replace "<!--Name-->",$Name `
		-replace "<!--Title-->",$title `
		-replace "<!--streetAddress-->",$streetAddress `
		-replace "<!--City-->",$City `
		-replace "<!--postalCode-->",$postalCode `
		-replace "<!--officePhone-->",$officePhone `
		-replace "<!--mobilePhone-->",$mobilePhone `
		-replace "<!--Company-->",$Company `		
		}
	
			
		if (!$title) {
			$fieldSplit = $templateWork -split "<!`-`-TitleC`-`->([^/]+)<!`-`-CTitleC`-`->"
			$templateWork = $templateWork -replace($fieldSplit[1],"")
			}
	
	    if (!$streetAddress) {
			$fieldSplit = $templateWork -split "<!`-`-streetAddressC`-`->([^/]+)<!`-`-CstreetAddressC`-`->"
			$templateWork = $templateWork -replace($fieldSplit[1],"")
			}
		
		if (!$city) {
			$fieldSplit = $templateWork -split "<!`-`-CityC`-`->([^/]+)<!`-`-CCityC`-`->"
			$templateWork = $templateWork -replace ($fieldSplit[1],"")
			}
			
		if (!$postalCode) {
			$fieldSplit = $templateWork -split "<!`-`-postalCodeC`-`->([^/]+)<!`-`-CpostalCodeC`-`->"
			$templateWork = $templateWork -replace ($fieldSplit[1],"")
			}
		
		if (!$officePhone) {
			$fieldSplit = $templateWork -split "<!`-`-officePhoneC`-`->([^/]+)<!`-`-CofficePhoneC`-`->"
			$templateWork = $templateWork -replace ($fieldSplit[1],"")
			}
		
		if (!$mobilePhone) {
			$fieldSplit = $templateWork -split "<!`-`-mobilePhoneC`-`->([^/]+)<!`-`-CmobilePhoneC`-`->"
			$templateWork = $templateWork -replace ($fieldSplit[1],"")
			}
		
		if (!$company) {
			$fieldSplit = $templateWork -split "<!`-`-companyC`-`->([^/]+)<!`-`-CcompanyC`-`->"
			$templateWork = $templateWork -replace ($fieldSplit[1],"")
			}
		
		$templateWork | Out-File $sigpath
}