LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Whats wrong with this code?

What I'm trying to do is access my outlook inbox and grab all unread
emails, received today, with subject containing "string here".
After grabbing I'm placing tab delimited data in Excel.

The above works fine almost (I'm unable to limit to just unread)

The following is where it's breaking.

Next I need to move processed emails to another folder.
When I run this macro - which I built based on code from this group.
The code is loading the emails I expect into Excel but it's moving all
unread emails to another folder.
I only want the items I process that met first series of condition

Thoughts
Steve
**** Start Code ****
Sub GetTradeSignal()
On Error Resume Next

Dim olApp As Outlook.Application
Dim olNs As NameSpace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim sStr As String
Dim arr As Variant
Dim i As Integer
Dim x As Long

Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
i = 1

For Each olMail In Fldr.Items
If olMail.UnRead = True And _
InStr(olMail.Subject, "C2:Trade:") 0 And _
Int(olMail.ReceivedTime) = Date Then
sStr = olMail.Body
arr = Split(sStr, " ")
x = UBound(arr) - LBound(arr) + 1
ActiveSheet.Cells(i, 1).Resize(1, x).Value = arr
i = i + 1
End If
olMail.UnRead = False
olMail.Move Fldr.Folders("Archived")
Next olMail

Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing

End Sub
****End CODE *****

 
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
Whats wrong with this code? Joseph[_54_] Excel Programming 2 November 26th 04 04:31 PM
Whats Wrong with this?? drvortex Excel Worksheet Functions 1 October 30th 04 06:48 PM
Whats wrong with this line of code? Edgar Thoemmes[_4_] Excel Programming 4 October 26th 04 12:52 PM
whats wrong with this code LiSa Excel Programming 2 September 8th 04 05:47 PM
Whats wrong with this code gav meredith Excel Programming 5 April 21st 04 12:01 AM


All times are GMT +1. The time now is 06:37 AM.

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

About Us

"It's about Microsoft Excel"