question

PeterKarlstromMidrange avatar image
0 Votes"
PeterKarlstromMidrange asked PeterKarlstromMidrange edited

Turning on and off Mail sound

Hi

I want to turn mail sound on and off programmatically using Visual Basic or C#.

The settings used in previous versions of Windows was located in the registry’s CURRENT_USER AppEvents\Schemes\Apps.Default\MailBeep folder, but this settings seems to be ignored.

I have found bits of settings in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Outlook\Settings\Data\global_Mail_PlaySound, but changing the value in code has no effect in the client.

I don’t want to turn off sound totally, I just want to change the setting for mail sound to on or off using some code in VB or C# with an application argument.

This code does not do the trick:
Dim comArgs() As String = Environment.GetCommandLineArgs

 For Each comArg In comArgs
     If comArg.ToLower.Contains("/on") Then
         'Sätt på ljudet
         Dim setValue As String = "{""name"":""Mail_PlaySound"",""itemClass"":""roamingsetting"",""id"":""RgAAAAA0zT-l4Q-tQLHwADYCw-ouBwDtV__ZDum8T7CsDsO5wuSsAAIBrEpfAADtV__ZDum8T7CsDsO5wuSsAAJfiXx-AAAA0"",""scope"":""Global"",""parentSetting"":"""",""secondaryKey"":"""",""status"":""SYNCEDTOSERVICE"",""type"":""Bool"",""timestamp"":0,""metadata"":"""",""value"":""true"",""isFirstSync"":""false""}"
         My.Computer.Registry.SetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Outlook\Settings\Data", "global_Mail_PlaySound", setValue)
         Exit For
     End If
     If comArg.ToLower.Contains("/off") Then
         'Stäng av ljudet                
         Dim setValue As String = "{""name"":""Mail_PlaySound"",""itemClass"":""roamingsetting"",""id"":""RgAAAAA0zT-l4Q-tQLHwADYCw-ouBwDtV__ZDum8T7CsDsO5wuSsAAIBrEpfAADtV__ZDum8T7CsDsO5wuSsAAJfiXx-AAAA0"",""scope"":""Global"",""parentSetting"":"""",""secondaryKey"":"""",""status"":""SYNCEDTOSERVICE"",""type"":""Bool"",""timestamp"":0,""metadata"":"""",""value"":""false"",""isFirstSync"":""false""}"
         My.Computer.Registry.SetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Outlook\Settings\Data", "global_Mail_PlaySound", setValue)
         Exit For
     End If
 Next


Has anybody any idea on how to do this?

Regards
Peter Karlström

dotnet-csharpoffice-outlook-itprodotnet-visual-basic
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @PeterKarlstromMidrange ,
Do you consider turning off outlook notification?
Here's a reference you may need: Disable outlook 2003 toast notification programmatically?


0 Votes 0 ·

Hi
This value is not present for Office 2019 (16.0),
It seems that Microsoft is moving away a lot of settings from Registry.
Ii is also not my task here. I just want to switch the setting on/off on the mail notice sound.

A way would be to change the settings for "Notify on new email" in the dialog for sounds in Control Panel, but these values hals also been hidden away somehere.

Why are Microsoft doing this and then don't give any answers on how to solve issues regarding this?

0 Votes 0 ·

HKEY_CURRENT_USER\AppEvents\Schemes\Apps.Default\MailBeep.Current
works on my configuration (I have Sea Monkey as Mail client, on Windows 10)

0 Votes 0 ·

Hi
Thanks for your reply.

This was my former solution which worked for Outlook up to version 2013 I think.
Since then Microsoft has a new "strategy".
The values in this area of the Registry don't seem to affect Outlook 2019 at all.

0 Votes 0 ·
Castorix31 avatar image Castorix31 PeterKarlstromMidrange ·

I just did a test with Outlook 2016 and the sound is in
HKEY_CURRENT_USER\AppEvents\Schemes\Apps.Default\Notification.Default\.Current
But I don't know for 2019....

0 Votes 0 ·

1 Answer

PeterKarlstromMidrange avatar image
0 Votes"
PeterKarlstromMidrange answered PeterKarlstromMidrange edited

Hi

You got me on the right track there. Thanks
The actual value for mail sound is here:
HKEY_CURRENT_USER\AppEvents\Schemes\Apps.Default\Notification.Mail.Current.
Another misleading fact is that the filename is translated to Swedish, so I didn't find it with a search in the Registry.

This is the new code:

Sub main()

 Dim comArgs() As String = Environment.GetCommandLineArgs

 For Each comArg In comArgs
     If comArg.ToLower.Contains("/on") Then
         'Turn on sound
         Dim setValue As String = "C:\WINDOWS\media\notify.wav"
         My.Computer.Registry.SetValue("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\Notification.Mail\.Current", "", setValue)
         Exit For
     End If
     If comArg.ToLower.Contains("/off") Then
         'Torn sound off
         Dim setValue As String = ""
         My.Computer.Registry.SetValue("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\Notification.Mail\.Current", "", setValue)
         Exit For
     End If
 Next

End Sub

Thanks.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.