Quick Search for:  in language:    
mail,arrives,your,Microsoft,Outlook,Inbox,sen
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 196,174. lines
 Jobs: 107. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login


 

 


Latest Code Ticker for ASP/ VbScript.
Automatic Form Insertion To Database
By Yasar Bayar on 1/11


Click here to see a screenshot of this code!Find Closest Physical Location (based on zip code, etc)
By Mark Kahn on 1/11

(Screen Shot)

String --> SQL Search Query
By Mark Kahn on 1/11


Replace text/Numbers for Images...
By Kenneth Nilsson on 1/9


INSERT sentence generator
By Eitan Rousso on 1/8


Employee Time Clock
By Dennis F. Corbitt on 1/8


[[_____Send Email through ASP , ( CDO ) mail
By Prince Joseph vm on 1/8


Click here to see a screenshot of this code!Debug Info v2.1 - Page footer based info display
By Hunter Beanland on 1/7

(Screen Shot)

inTouch Web Desk
By Gary Cowling on 1/6


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Text-to-Speech in MS Outlook

Print
Email
 

Submitted on: 11/18/2003 6:06:48 PM
By: Nick Sumner  
Level: Intermediate
User Rating: By 1 Users
Compatibility:VbScript (browser/client side)

Users have accessed this article 1593 times.
 
(About the author)
 
     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...   
1) 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.   
2) 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.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) 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"

Genie.MoveTo 100,100
Genie.Show
Wscript.Sleep 200
Genie.Speak (txt)

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

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this article(in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
11/19/2003 3:07:17 AM:Nicolas ROBIOLLE
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 ?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
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
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/19/2003 11:31:17 AM:
*lol* that makes a LOT of fun :) thanks for this howto!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
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
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/20/2003 5:33:54 AM:Nick Sumner
<p> 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. <p> Theres a diagram here: <br> www.tele-pro.co.uk/scripts/ newmail/speak.htm

Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
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
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
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?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/26/2003 8:14:34 AM:Nick Sumner
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?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular article, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.