Consulting

Results 1 to 3 of 3

Thread: Solved: Capturing Flag status of mail in Execl from Outlook

  1. #1
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location

    Exclamation Solved: Capturing Flag status of mail in Execl from Outlook

    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.



    Sudhir

  2. #2
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location
    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

  3. #3
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •