Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm about 3/4 of the way there. I'm tyring to learn Outlook features in VBA.
I got the latest message but trying to figure out how to read the body of the message. There are 3 things you need to do 1) To the VBA reference add Outlook object VBA menu Tools - References - Microsoft Outlook 10.o Object Library - Check box and press Add. Use the latest version that is on your computer. 2) You need to Insert (from Inset VBA menu) a Class Module to you VBA project called Class1. I'm using AdvanceSearch which is looking at your inbox and finding the messages received today with LOCK in the subject. AdvanceSearch triggers an event that can only be recognized in a class module. The Class module when an event occurs sets blnSearchComp TRUE and trigger the DoEvent in the module code. Add this code to the class module Public WithEvents olApp As Outlook.Application Private m_sch As Outlook.Search Public Sub AdvSearch(MyScope As String, MyFilter As String, _ ByRef m_sch) Set m_sch = olApp.AdvancedSearch(MyScope, MyFilter) End Sub Private Sub Class_Initialize() Set Me.olApp = CreateObject("Outlook.Application") Set myNamespace = Me.olApp.GetNamespace("MAPI") Set myfolder = myNamespace.GetDefaultFolder(olFolderInbox) End Sub Private Sub Class_Terminate() Set Me.olApp = Nothing End Sub Private Sub olApp_AdvancedSearchComplete(ByVal SearchObject As Outlook.Search) blnSearchComp = True End Sub 3) This code is the module code where all your programming can be written. the code calls the Class1 modules to initialize the search. Add the code to a regular Module (not a class module). Public blnSearchComp As Boolean Public g_clsTest As Class1 Sub GetMail() Const strS As String = "Inbox" Dim strF As String Dim sch As Outlook.Search Dim rsts As Outlook.Results strF = "urn:schemas:httpmail:" & _ "subject LIKE '%Lock%' AND" & _ "%today(urn:schemas:httpmail:datereceived)%" blnSearchComp = False Set g_clsTest = New Class1 g_clsTest.AdvSearch strS, strF, sch While blnSearchComp = False DoEvents Wend Set rsts = sch.Results rsts.Sort "ReceivedTime", Descending:=True Set LastestMess = rsts.Item(1) End Sub "Ranjit kurian" wrote: i need a macro to open the lastest (for that day) outlook mail in inbox which has subject begins with Lock and in that mail there is a table with four columns, the macro should go to column called as Net and add the amount(amount is given below the heading) with next column called as Gross (amount is given below the heading) and paste in excel active cell. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Auto Open file to run Mail macro | Excel Programming | |||
Using Currently Open Lotus Notes Mail Server Info in Excel Macro | Excel Programming | |||
Macro to automatically open a website or send an e-mail in excel | Excel Discussion (Misc queries) | |||
Macro to Copy data from e-mail and paste it into a field on a website | Excel Programming | |||
Excel macro to open word mail merge | Excel Programming |