Introduction:
This article clearly explains about how to automate or force the Send/Receive event in the outlook using vb.net. This code can be used as a service and made to automate the Send/Receive event in the outlook for a regular interval.
Summary:
The following steps will help us to create the application.
Step 1: Start Microsoft Visual Studio .NET.
Step 2: On the File menu, click New, and then click Project.
Step 3: Click Visual Basic Projects under Project Types, and then click Console Application under Templates. By default, Module1.vb is created.
Step 4: Add a reference to the Microsoft Outlook 10.0/11.0 Object Library. To do this, follow these steps:
-
On the Project menu, click Add Reference.
-
On the COM tab, click Microsoft Outlook 10.0/11.0 Object Library, and then click Select.
-
Click OK in the Add References dialog box to accept your selections. If you are prompted to generate wrappers for the library that you selected, click Yes.
Step 5: In the Code window, replace all of the code with the following:
Automate Send & Receive:
Imports System.Reflectio
Module Module1
Sub Main()
Try
'Microsoft.Office.Interop.Outlook._Application
' Create an Outlook application.
Dim oApp As Outlook._Application = New Outlook.Application
' Get the MAPI NameSpace and Logon values.
Dim oNS As Outlook._NameSpace = CType(oApp.GetNamespace("MAPI"),
outlook._NameSpace)
oNS.Logon(Missing.Value, Missing.Value, True, True)
'Get Explorer for the folder.
Dim oExp As Outlook._Explorer = oFolder.GetExplorer(False)
'Get the Menu bar.
Dim oCmdBars As office._CommandBars = oExp.CommandBars
Dim oCmdBar As office.CommandBar = oCmdBars("Menu Bar")
Console.WriteLine(oCmdBar.Name)
Dim oBarCrls As office.CommandBarControls = oCmdBar.Controls
Join the conversation! Your thoughts help the community grow.