Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Retrieve Outlook mails from Excel

Hi,
I have a list of loans for which Reports are prepared and stored in the PST
folder. Now we need the attachments of these Reports to be stored in a
specified folder (C:\Documents and
Settings\sundarak\Desktop\OLAttachments).The number of loans range in 1000s
and I need to filter these from PST at once. I have the list of loans in
Excel. Can I filter these loans at once?

Thanks
Kiran

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Retrieve Outlook mails from Excel

1) Where are the loan numbers or all you extracting all mail? If you are
extractingg only some of the loans how do you identify each e-mail (subject
line contain loan number)?
2) Is the PST data in your e-mail account or is it an archieve that needs to
be opened?
3) Which folder in you e-mail account is the loans?
4) How manuy attachments are in each e-mail?
5) Arre the attachments in word, excel or some other format?

"Kiran" wrote:

Hi,
I have a list of loans for which Reports are prepared and stored in the PST
folder. Now we need the attachments of these Reports to be stored in a
specified folder (C:\Documents and
Settings\sundarak\Desktop\OLAttachments).The number of loans range in 1000s
and I need to filter these from PST at once. I have the list of loans in
Excel. Can I filter these loans at once?

Thanks
Kiran

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Retrieve Outlook mails from Excel

Hi Joel,

1. I have extracted the Loan Number from the subject line and that needs to
be compared with the data in excel sheet.
2. The Foreclosure Reports are archived in a pst folder present in a Server.
3. The Loan numbers are in excel sheet and not in any folder. The path of
that is C:\Loans.xls
4. The attachments are in pdf format.

I just need to know how to filter the mails in pst at once.


"joel" wrote:

1) Where are the loan numbers or all you extracting all mail? If you are
extractingg only some of the loans how do you identify each e-mail (subject
line contain loan number)?
2) Is the PST data in your e-mail account or is it an archieve that needs to
be opened?
3) Which folder in you e-mail account is the loans?
4) How manuy attachments are in each e-mail?
5) Arre the attachments in word, excel or some other format?

"Kiran" wrote:

Hi,
I have a list of loans for which Reports are prepared and stored in the PST
folder. Now we need the attachments of these Reports to be stored in a
specified folder (C:\Documents and
Settings\sundarak\Desktop\OLAttachments).The number of loans range in 1000s
and I need to filter these from PST at once. I have the list of loans in
Excel. Can I filter these loans at once?

Thanks
Kiran

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Retrieve Outlook mails from Excel

I've done something like this before where I had to extact tables from
filtered e-mail messages. Becuase the tables were in HTML format I used an
internet explorere to get the tables which you don't need to do but included
the code.

To do the advance filtering like you would manualy in outlook you need to
have a simple class module. I've attached the code I used before below.The
filtering was done with this statement

strF = "urn:schemas:httpmail:" & _
"subject LIKE '%Lock%' AND" & _
"%today(urn:schemas:httpmail:datereceived)%"

I got the syntax for the above statement by recording a macro and then
performed the filtering manually.The took the recorded macro and used in my
macro below.


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
Const ForReading = 1, ForWriting = 2, _
ForAppending = 3
Dim TBL As Object

TempPath = Environ("Temp")
FName = TempPath & "\OutlookTMP.HTML"


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
If rsts.Count = 0 Then
MsgBox ("No messages found - Exiting Sub")
Exit Sub
End If
rsts.Sort "ReceivedTime", Descending:=True
Set LatestMess = rsts.Item(1)


Set fs = CreateObject("Scripting.FileSystemObject")
Set fout = fs.CreateTextFile _
(FName, True)
fout.Write LatestMess.HTMLBody
fout.Close

'desroy class object
Set g_clsTest = Nothing

'Set IEObj = GetObject(FName)
Set IE = CreateObject("INternetExplorer.Application")
IE.Application.Visible = True
URL = FName
IE.Navigate2 URL
Do While IE.readyState < 4
DoEvents
Loop

Set TBL = IE.document.getelementsbytagname("Table")

'find Net and Gross
'Set statement below causes errors

Set TBLRows = TBL.Item(0).Rows


Set RowOne = TBLRows.Item(0)
Set RowTwo = TBLRows.Item(1)
For i = 0 To (RowOne.Children.Length - 1)
If UCase(RowOne.Children.Item(i).innertext) = "NET" Then
NetCol = i
End If
If UCase(RowOne.Children.Item(i).innertext) = "GROSS" Then
GrossCol = i
End If

Next i
Net = Val(RowTwo.Children.Item(NetCol).innertext)
Gross = Val(RowTwo.Children.Item(GrossCol).innertext)
Total = Net + Gross
ActiveCell.Value = Total

IE.Application.Quit
End Sub

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

regular module
-------------------------------------------------------------------------------------


"Kiran" wrote:

Hi Joel,

1. I have extracted the Loan Number from the subject line and that needs to
be compared with the data in excel sheet.
2. The Foreclosure Reports are archived in a pst folder present in a Server.
3. The Loan numbers are in excel sheet and not in any folder. The path of
that is C:\Loans.xls
4. The attachments are in pdf format.

I just need to know how to filter the mails in pst at once.


"joel" wrote:

1) Where are the loan numbers or all you extracting all mail? If you are
extractingg only some of the loans how do you identify each e-mail (subject
line contain loan number)?
2) Is the PST data in your e-mail account or is it an archieve that needs to
be opened?
3) Which folder in you e-mail account is the loans?
4) How manuy attachments are in each e-mail?
5) Arre the attachments in word, excel or some other format?

"Kiran" wrote:

Hi,
I have a list of loans for which Reports are prepared and stored in the PST
folder. Now we need the attachments of these Reports to be stored in a
specified folder (C:\Documents and
Settings\sundarak\Desktop\OLAttachments).The number of loans range in 1000s
and I need to filter these from PST at once. I have the list of loans in
Excel. Can I filter these loans at once?

Thanks
Kiran

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Retrieve Outlook mails from Excel

I've done something like this before where I had to extact tables from
filtered e-mail messages. Becuase the tables were in HTML format I used an
internet explorere to get the tables which you don't need to do but included
the code.

To do the advance filtering like you would manualy in outlook you need to
have a simple class module. I've attached the code I used before below.The
filtering was done with this statement

strF = "urn:schemas:httpmail:" & _
"subject LIKE '%Lock%' AND" & _
"%today(urn:schemas:httpmail:datereceived)%"

I got the syntax for the above statement by recording a macro and then
performed the filtering manually.The took the recorded macro and used in my
macro below.


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
Const ForReading = 1, ForWriting = 2, _
ForAppending = 3
Dim TBL As Object

TempPath = Environ("Temp")
FName = TempPath & "\OutlookTMP.HTML"


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
If rsts.Count = 0 Then
MsgBox ("No messages found - Exiting Sub")
Exit Sub
End If
rsts.Sort "ReceivedTime", Descending:=True
Set LatestMess = rsts.Item(1)


Set fs = CreateObject("Scripting.FileSystemObject")
Set fout = fs.CreateTextFile _
(FName, True)
fout.Write LatestMess.HTMLBody
fout.Close

'desroy class object
Set g_clsTest = Nothing

'Set IEObj = GetObject(FName)
Set IE = CreateObject("INternetExplorer.Application")
IE.Application.Visible = True
URL = FName
IE.Navigate2 URL
Do While IE.readyState < 4
DoEvents
Loop

Set TBL = IE.document.getelementsbytagname("Table")

'find Net and Gross
'Set statement below causes errors

Set TBLRows = TBL.Item(0).Rows


Set RowOne = TBLRows.Item(0)
Set RowTwo = TBLRows.Item(1)
For i = 0 To (RowOne.Children.Length - 1)
If UCase(RowOne.Children.Item(i).innertext) = "NET" Then
NetCol = i
End If
If UCase(RowOne.Children.Item(i).innertext) = "GROSS" Then
GrossCol = i
End If

Next i
Net = Val(RowTwo.Children.Item(NetCol).innertext)
Gross = Val(RowTwo.Children.Item(GrossCol).innertext)
Total = Net + Gross
ActiveCell.Value = Total

IE.Application.Quit
End Sub

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

regular module
-------------------------------------------------------------------------------------


"Kiran" wrote:

Hi Joel,

1. I have extracted the Loan Number from the subject line and that needs to
be compared with the data in excel sheet.
2. The Foreclosure Reports are archived in a pst folder present in a Server.
3. The Loan numbers are in excel sheet and not in any folder. The path of
that is C:\Loans.xls
4. The attachments are in pdf format.

I just need to know how to filter the mails in pst at once.


"joel" wrote:

1) Where are the loan numbers or all you extracting all mail? If you are
extractingg only some of the loans how do you identify each e-mail (subject
line contain loan number)?
2) Is the PST data in your e-mail account or is it an archieve that needs to
be opened?
3) Which folder in you e-mail account is the loans?
4) How manuy attachments are in each e-mail?
5) Arre the attachments in word, excel or some other format?

"Kiran" wrote:

Hi,
I have a list of loans for which Reports are prepared and stored in the PST
folder. Now we need the attachments of these Reports to be stored in a
specified folder (C:\Documents and
Settings\sundarak\Desktop\OLAttachments).The number of loans range in 1000s
and I need to filter these from PST at once. I have the list of loans in
Excel. Can I filter these loans at once?

Thanks
Kiran

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert outlook mails as attachemnt without inserting as object Radhakant Panigrahi Excel Discussion (Misc queries) 0 April 16th 10 05:36 AM
signal for incoming mails in outlook express oercim Excel Programming 1 March 30th 06 01:59 PM
Import of Outlook Mails to Excel Sheet Ajay Setting up and Configuration of Excel 6 July 24th 05 11:39 PM
sending mails using outlook Bart van den Burg Excel Programming 1 November 11th 04 12:51 PM
retreiving number of e-mails from public folder in Outlook Barmaley Excel Programming 1 July 15th 03 09:47 PM


All times are GMT +1. The time now is 03:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"