jeudi 26 avril 2018

Migration : VBS : PS :Signature Outlook



Si vous souhaitez enregistrer le nom des signatures utilisées pour les nouveaux emails et réponse dans Outlook, voici un petit script VBS (et PowerShell) pour afficher ces informations.

VBS:

Const ForReading = 1, ForWriting = 2
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")


Set objWord = CreateObject("Word.Application")
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature

msgbox (objSignatureObject.NewMessageSignature)
Set f = fso.OpenTextFile("c:\temp\mail_signature_new.txt", ForWriting,true)
f.write(objSignatureObject.NewMessageSignature)

msgbox (objSignatureObject.ReplyMessageSignature)
Set f = fso.OpenTextFile("c:\temp\mail_signature_rep.txt", ForWriting,true)
f.write(objSignatureObject.ReplyMessageSignature)
'objSignatureObject.ReplyMessageSignature = "Signature"

PowerShell: 

#Set the signature as default for new emails
$MSWord = New-Object -ComObject word.application
$EmailOptions = $MSWord.EmailOptions
$EmailSignature = $EmailOptions.EmailSignature

$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup($EmailSignature.NewMessageSignature,0,"Done",0x1)
$wshell.Popup($EmailSignature.ReplyMessageSignature,0,"Done",0x1)

$file = new-item "c:\temp\email_new.txt" –type file -force
add-content $file $EmailSignature.NewMessageSignature

$file = new-item "c:\temp\email_rep.txt" –type file -force
add-content $file $EmailSignature.ReplyMessageSignature

#$EmailSignature.NewMessageSignature = "agadou" #insert the signature name
#$EmailSignature.ReplyMessageSignature ="agadou"

$MSWord.Quit()

Aucun commentaire:

Enregistrer un commentaire