-
Thanks gmayor,
The sound file is a sound effect of a cash register (cha-ching) so I would want the sound to play to alert me of a sale then "25.tour_booked" and "25.tour_price" to be read out after the sound has stopped playing (2 second clip) I had this working (with my code above in my 2nd post) using outlook rules to play the sound then run the script (reading out the subject line) and I added a 2 second delay to the text being read out but I cannot seem to get this working again now.
I am currently using this:
Public Sub AnnounceMail(olItem As Outlook.MailItem)
Dim sText As String
Dim sSubject1 As String, sSubject2 As String
Dim vText As Variant, vItem As Variant
Dim i As Long
sText = olItem.Body
vText = Split(sText, Chr(13))
For i = 1 To UBound(vText)
If InStr(1, vText(i), "5.tour_booked : ") > 0 Then
vItem = Split(vText(i), Chr(58))
sSubject1 = "Tour booked, " & Trim(vItem(1))
End If
If InStr(1, vText(i), "5.tour_price : ") > 0 Then
vItem = Split(vText(i), Chr(58))
sSubject2 = "Price " & Trim(vItem(1))
End If
Next i
'The separation provides better expression of the texts
SpeakText sSubject1
SpeakText sSubject2
lbl_Exit:
Exit Sub
End Sub
Private Sub SpeakText(strText As String)
Dim speech As SpVoice
On Error Resume Next
Set speech = New SpVoice
speech.Speak strText, _
SVSFlagsAsync + SVSFPurgeBeforeSpeak
Do
DoEvents
Loop Until speech.WaitUntilDone(10)
Set speech = Nothing
End Sub
Sub TestMsg()
Dim olMsg As MailItem
On Error Resume Next
Set olMsg = ActiveExplorer.Selection.Item(1)
AnnounceMail olMsg
lbl_Exit:
Exit Sub
End Sub
This reads out the 2 lines but only if the email has the 5.tour_booked if it has the 25.tour_booked nothing happens.
Thanks
Simmons
Last edited by Simmons; 07-08-2015 at 12:47 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules