A while ago I blogged about a script that I use the auto generate users Outlook Signatures based on information stored in active directory. This is still being used and still works well, it’s been slightly modified over the months, but essentially it’s the same.
Management decided the other day that they would like recent news items to be displayed in the signatures too, so I went about modifying the script.
I wanted management to be able to modify the news feed item without needing to contact me, so opted for a simple text file stored on a network share in the office.
\\Server\Folder\newsitem.txt
BBC: Bean bag exercises help man deal with dyslexia|http://bbc.in/toXgNC
(I use bit.ly to create the short links, I can then also monitor the traffic generated from this from the chrome bit.ly plugin)
As it stands it’s just one news item, but I plan to increase this so in future it will pull multiple stories. The title and link are separated by a vertical bar on the same line.
Anyway, this is the modified code which I inserted towards the top of the script
‘Get news story from flat file
Const ForReading = 1
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objTextFile = objFSO.OpenTextFile _
(“n:\news\emailnews.txt”, ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , “,”)
‘Wscript.Echo arrServiceList(0)
Loop
strNewsarray = split(arrServiceList(0),”|”)
‘New Story Title
strNewsStoryTitle = strNewsarray(0)
‘New Story Link
strNewsStoryLink = strNewsarray(1)
It basically opens the file, stick the content into an array then loops through this array, splits the news from the link and then puts these items against the variables. Hopefully soon I’ll finish the code so it can support multiple stories.
Then later in the script the following code runs:
‘check if there is any news
if (strNewsStoryTitle <> “”) then
‘double line break
objSelection.TypeParagraph()
objSelection.TypeParagraph()
‘Latest news
objSelection.Font.Size = “8″
objSelection.Font.Color = RGB(10,10,10)
objSelection.Font.Name = “Arial”
objSelection.Font.Bold = true
objSelection.TypeText “Latest Dore News…”
‘line break
objSelection.TypeParagraph()
objSelection.Hyperlinks.Add objSelection.Range, strNewsStoryLink, “”, “”, strNewsStoryTitle
end if
Which basically checks that the news item is not empty, and then adds a sub heading and then lists the hyperlinked news item.
