/build/static/layout/Breadcrumb_cap_w.png

Quote for the day in Email Signature

Automating the outlook signature involves many things by gathering information from AD, environmental variable and so on.

We have seen people using inspirational quotes in bottom of their signature and periodically they change the quotes. How about every day new quote in their signature that too automated.

This blog is about the automation of quotes in to signature.

I am getting quotes from http://www.eduro.com/ Thanks to Eduro


$AppData=$env:appdata

$SigPath = '\Microsoft\Signatures'

$LocalSignaturePath = $AppData+$SigPath

 

Signature information will be available in C:\Users\<username> \AppData\Roaming\Microsoft\Signatures

if (!(Test-path "$LocalSignaturePath\signaturecustom.txt")){

@"

First and Last Name

Title | Group

CompanyName| Direct phone | Mobile phone | firstname.lastname@company.com 

"@ | out-file "$LocalSignaturePath\signaturecustom.txt"

 

}

 

It will create a text file in the C:\Users\<username> \AppData\Roaming\Microsoft\Signatures\signaturecustom.txt for the first time

This file needs to be changed as per user data.

Here comes the web scrapping

$url = "http://www.eduro.com/"

$r1= Invoke-WebRequest -Uri $url

$r4=@{}

$r2=($r1.ParsedHtml.getElementsByTagName('p') )[0]

$r4[1]=$r2.innerText

$r3=($r1.ParsedHtml.getElementsByTagName('p') )[1]

$r4[0]=$r3.innerText

 

 uJX2Mp.jpeg

 

N9edXw.jpeg 

Note: signaturecustom.txt text needs to be modified as per your signature.

Once signaturecustom template is selected from signature Ribbon Button from outlook.it will display the output like this.

At last you can schedule it in task scheduler.

Full Script.

$AppData=$env:appdata 

$SigPath = '\Microsoft\Signatures' 

$LocalSignaturePath = $AppData+$SigPath 

if (!(Test-path "$LocalSignaturePath\signaturecustom.txt")){

@"

First and Last Name

Title | Group

CompanyName| Direct phone | Mobile phone | firstname.lastname@company.com  

"@ | out-file "$LocalSignaturePath\signaturecustom.txt"


}

$url = "http://www.eduro.com/"

$r1= Invoke-WebRequest -Uri $url

$r4=@{}

$r2=($r1.ParsedHtml.getElementsByTagName('p') )[0]

$r4[1]=$r2.innerText

$r3=($r1.ParsedHtml.getElementsByTagName('p') )[1]

$r4[0]=$r3.innerText

$r4.Values 

$input= Get-content  "$LocalSignaturePath\signaturecustom.txt"

$stream = [System.IO.StreamWriter] "$LocalSignaturePath\Signaturecustom.htm"

$stream.WriteLine("<!DOCTYPE HTML PUBLIC `"-//W3C//DTD HTML 4.0 Transitional//EN`">")

$stream.WriteLine("<HTML><HEAD><TITLE>Signature</TITLE>")

$stream.WriteLine("<META http-equiv=Content-Type content=`"text/html; charset=windows-1252`">")

$stream.WriteLine("<BODY>")

$stream.WriteLine("<SPAN style=`"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: `'Trebuchet MS`'`">")

$stream.WriteLine("<BR><BR>")

$stream.WriteLine("<B><SPAN style=`"FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: `'Trebuchet MS`'`">" + ($input[0].ToUpper()).Substring(0,$input[0].Length) + "</SPAN></B>")

$stream.WriteLine("<SPAN style=`"FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: `'Trebuchet MS`'`">")

$stream.WriteLine("<BR><BR>")

$input=(Get-content  "C:\Users\raviregi\Desktop\Test.txt" )| Select-Object -Skip 1

foreach( $value in  $input) {

$stream.WriteLine("<SPAN style=`"FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: `'Trebuchet MS`'`">" + $value +"</SPAN>")

$stream.WriteLine("<BR><BR>")

}

$stream.WriteLine("<SPAN style=`"FONT-SIZE: 7pt; FONT-STYLE: 'italic';COLOR: gray; FONT-FAMILY: `'Trebuchet MS`'`">" + $r4.Values +"</SPAN>")

$stream.WriteLine("<BR>")

$stream.WriteLine("</BODY>")

$stream.WriteLine("</HTML>")

$stream.close()


Script Posted in TechNet


Comments

This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ