View Full Version : Solved: Capturing Flag status of mail in Execl from Outlook
kbsudhir
12-05-2007, 02:15 PM
Hi All,
I am trying to capture, the flag status of the mail in outlook to excel via excel. but I am unsucessful.
I am able to capture the same from outlook to excel by creating a macro in outlook but that will be too round about way for me.
Hence I want some guidance to capture the same by creating a macro in excel.
Any help in this regard is greatly appreciated.
:dunno
Sudhir
kbsudhir
12-05-2007, 05:20 PM
Hi Guys,
I figured a way out, i still till don't know will this work or not.
This is the code.
Sub Test()
Dim outapp As outlook.Application
Dim mail As outlook.MailItem
Dim fld As outlook.MAPIFolder
Dim fld_path As Object
Dim items1 As Object
Dim flagclr As Integer
Dim count As Integer
Set fld_path = fld.Folders("Mailbox - Balakrishna, Sudhir - OSP").Folders("Inbox")
fldp = fld_path.FolderPath
count = 1
Set items1 = fldp.Items
For Each Item In items1
flagclr = Item.FlagIcon
If flagclr = 5 Then
Range("A" & count).Value = Item.ReceivedTime
End If
count = count + 1
Next Item
End Sub
Here in the line:
Set fld_path = fld.Folders("Mailbox - Balakrishna, Sudhir - OSP").Folders("Inbox")
Iam getting Error:
"Object Variable or With Block Variable not set"
Can somebody provide me a solution for this, so that I can test rest of the code too.
Please help
Sudhir
kbsudhir
12-06-2007, 10:52 AM
This the way to capture the receined time as per the flag status. In this case Flag is Red.
Sub Cap_Dat_Tim()
Dim fld_path As Object
Dim flagclr As Integer
Dim str As String, dat As String, tme As String
Set abd = Outlook.GetNamespace("MAPI")
Set fld_path = abd.Folders("Mailbox - Balakrishna, Sudhir - OSP").Folders("Inbox")
count = 1
For Each Item In fld_path.Items
flagclr = Item.FlagIcon
If flagclr = 6 Then
str = Item.ReceivedTime
tme = Trim(Right(str, 11))
dat = Trim(Replace(str, tme, ""))
Range("G1").Value = dat
Range("G2").Value = tme
Exit Sub
End If
Next Item
End Sub
Thanks
Sudhir
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.