- Outlook 2007+ Macro - Send/Receive specific group with macro (VBScript)
- Specifically send/receives "Gmail" group in Outlook.
Derived from http://msdn.microsoft.com/en-us/library/bb206704(v=office.12).aspx example.
Public Sub Gmail()
Dim nsp As Outlook.NameSpace
Dim sycs As Outlook.SyncObjects
Dim syc As Outlook.SyncObject
Dim i As Integer
Rem Dim strPrompt As Integer
Set nsp = Application.GetNamespace("MAPI")
Set sycs = nsp.SyncObjects
For i = 1 To sycs.Count
Set syc = sycs.Item(i)
Rem strPrompt = MsgBox("Do you wish to synchronize " & syc.Name & "?", vbYesNo)
Rem If strPrompt = vbYes Then
If syc.Name = "Gmail" Then
syc.Start
End If
Next
End Sub
NB: To create a send/receive group -
1. Select File
2. Select Options
3. Select Advanced
4. Select Send and Receive.
5. Create a new group and configure in the dialogue.
To Create a personal digital signature to sign your macro -
1. Make sure the Office shared tools are installed (Digital Signature for VBA Projects to Run from My Computer)
2. Run Digital Signature for VBA Projects from the start menu and create a personal signature.
To Create a macro and digitally sign it -
1. Press Alt+F8
2. Type in a Name for the Macro
3. Choose Create
4. Use the VB Editor and paste the above code in
5. Choose Tools then Digital signature then the Choose button and select your Digital signature and OK.
5. Select file and Save
6. Select file and Close and Return to Microsoft Outlook
To create a button and assign macro to that button in ribbon and set Macro security -
1. Right hand click on the ribbon and choose Customize the Ribbon
2. Select Macros from the Choose command from: drop down list
3. Select the Macro you want to use
4. Choose the Tab you want to add button too and then the Group underneath
5. Click the New Group button and then click the Rename button and type in the name for the New Group and choose OK.
6. Click the Add >> button to add the macro to this New Group.
7. Click the Rename button and choose an Icon and Display name for the button and choose OK.
8. Choose OK to close the Outlook Options dialogue.
9. Select File then Options then Trust Center then click the Trust Center Settings... button
10. Choose Macro Settings and Select "Notifications for all macros" then OK and OK again to close the options dialogue.
11. Close Outlook and restart it.
12. Click the new button to do a first run of the new macro after restarting outlook and then click the "Trust all documents from this publisher" and your digital certicate will be stored as a trusted publisher.
Tutorials
Outlook 2007+ Macro - Send/Rec...
T: (08)9345 1129
P: PO Box 233, Tuart Hill WA 6939