When new mail arrives in your Microsoft Outlook Inbox, the sender and subject are read out aloud using the Microsoft text-to-speech control.
Terms of Agreement:
By using this article, you agree to the following terms...
You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
You may link to this article from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
Speech Synthesis of New Mail in Microsoft Outlook
When new mail arrives in your Microsoft Outlook Inbox, the sender and subject
are read out aloud using the Microsoft text-to-speech control. Uses Microsoft
Agent.
The code consists of two sections. The first is a VBS script, which is placed
on the hard drive with a '.vbs' extension - in this example, as C:\SpeakNewMail.vbs
This self-contained script includes a function to speak a text string with
the Microsoft Agent control, and accepts the text string as a parameter in the
command-line.
Code Listing 1 - SpeakNewMail.vbs
Place this script on your hard drive as C:\SpeakNewMail.vbs
Option Explicit
Dim args, num
set args = WScript.Arguments
num = args.Count
if num = 0 then WScript.Quit
Dim text
text = ""
Dim k
for k = 0 to num - 1
text = text & " " & args.Item(k)
next
Speak(text)
FUNCTION Speak(txt)
Dim GenieRequest
Dim Genie
Dim Agent1
If ScriptEngineMajorVersion < 2 Then
EXIT FUNCTION
Else
Set Agent1 = WScript.CreateObject("Agent.Control.2", "AgentControl_")
Agent1.Characters.Load "Genie", "http://agent.microsoft.com/characters/v2/genie/genie.acf"
Set Genie = Agent1.Characters("Genie")
Genie.Get "State", "Showing"
Wscript.Sleep (4000 + (200 * LEN(txt)) )
Genie.Hide
End If
END FUNCTION
Code Listing 2- ThisOutlookSession
The following code is placed in the ThisOutlookSession module of Microsoft
Outlook:
Private Sub Application_NewMail()
Dim oFolder
Dim oNewItem
Dim s
Set oFolder = GetNamespace("MAPI").GetDefaultFolder(6)
For Each oNewItem In oFolder.Items.Restrict("[Unread] = 0")
s = "Email from " & oNewItem.SenderName & ". Message - "
s = s & Trim(oNewItem.Subject)
Speak (Trim(s))
oNewItem.UnRead = 0
Next
End Sub
Public Function Speak(txt)
Dim spk As String
Dim t As String
t = " " & Trim(txt)
spk = "C:\SpeakNewMail.vbs"
spk = spk & " """ & t & """"
Call WSHRun(spk, 1, True)
End Function
Public Function WSHRun(strCmd As String, bVisible As Integer, bWait As Boolean)
'Shell run
Dim WSHShell
Set WSHShell = CreateObject("wscript.Shell")
WSHShell.Run strCmd, bVisible, bWait
Set WSHShell = Nothing
End Function
I place the code into "thisoutlooksession" and create the vbs file on the C: but when new mail arrives in outlook 2002 nothing append. I think outlook doesn't execute the application_newmail() sub.... what can I do for change this ? (If this comment was disrespectful, please report it.)
11/19/2003 5:17:51 AM:
Hi - first, ensure the vbs file can perform TTS, by calling it directly like this: wscript "C:\SpeakNewMail.vbs" "Hello World"
Secondly, ensure that your security in MS Outlook is set to Medium to allow the macro.
Get back to me if you still need assistance,
Nick
(If this comment was disrespectful, please report it.)
11/19/2003 11:31:17 AM:
*lol* that makes a LOT of fun :)
thanks for this howto!!! (If this comment was disrespectful, please report it.)
11/20/2003 5:23:48 AM:
Where i should i put the secnd part? Can you explain better? I´m using Outlook Express 6 Thanks (If this comment was disrespectful, please report it.)
From Outlook, open the Visual Basic Editor. In the
Project TreeView, the module ThisOutlookSession
already exists, probably blank. Open the
ThisOutlookSession module, and paste the code from
listing 2 into the code editor.
Theres a diagram here:
www.tele-pro.co.uk/scripts/newmail/speak.htm
(If this comment was disrespectful, please report it.)
11/21/2003 1:58:19 PM:
Hi I am getting a synatx error in Line 1 char 17 Code: 800A03EA , Microsoct VBScript Compliation error (If this comment was disrespectful, please report it.)
11/25/2003 1:21:58 PM:
I am unable to get the Project code to work in Outlook 2000. It seems to work fine if I try it from a command line... Does it have something to do with the location of my Outlook installation? (If this comment was disrespectful, please report it.)
RE: syntax error in Line 1, I've updated the code and it should now be OK.
RE: unable to get the Project code to work in Outlook 2000, can you confirm if your macro security is set to medium/low?
(If this comment was disrespectful, please report it.)
3/16/2004 4:49:18 AM:
Hi! - The script itself works fine with comand line parameters, but from Outlook 2003 nothing happens - Any ideas ?? (If this comment was disrespectful, please report it.)
3/16/2004 9:22:20 AM:
I could get this to run from the command line too, but not from Outlook 2000. I changed the security setting to Medium, still no luck. Now when I open Outlook it asks me to enable the macro(s). Is this just for this macro are am I opening the door for any macro? Think I will change my security setting back until I know for sure. (If this comment was disrespectful, please report it.)
6/1/2004 2:13:31 PM:
I'm running WinXPPro with Outlook2003. Running from a DOS prompt, I get a line 37 char 1 error: The character ID is not valid. Verify that ID has been defined and is spelled correctly. Code: 80042002, Source: Agent.Control.2.
Any clues? bradley.c.birth@lmco.com (If this comment was disrespectful, please report it.)
6/20/2004 4:51:13 AM:
I get the same exact thing as the last user, please email me if you have any solutions at ryan@XXXwinsauer.com without the XXX ofcourse (If this comment was disrespectful, please report it.)
7/8/2004 7:32:33 AM:
Problem there is that Microsoft have removed the genie agent from their website. Use this instead http://www.msagentring.org/chars/genie/genie.acf
You will need to replace the url called for the acf in the SpeakNewMail.vbs script
Dav e. (If this comment was disrespectful, please report it.)
7/12/2004 2:01:06 PM:
Fixed it, Thanks so much Dave (If this comment was disrespectful, please report it.)
8/6/2004 2:11:32 PM:
I ran the command wscript (If this comment was disrespectful, please report it.)
8/6/2004 2:14:49 PM:
I ran the wscript command but I get a Window saying that on line 37 char. 1 The character ID is not valid. Verify that ID has been defined and is spelled correctly... I'm running Windows XP and Outlook 2002. Please advice, Thanks!. (If this comment was disrespectful, please report it.)
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)