Link to home
Start Free TrialLog in
Avatar of zachvaldez
zachvaldezFlag for United States of America

asked on

How to reference items in the Inbox..

HI,
Can someone show me how to reference items in Inbox? I would like to have the option to select the items or
all( meaning it would loop to all items in the inbox) without selection.
SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zachvaldez

ASKER

'Code for whatever it is you want to do>> thanks can you show me some examples that can be done in this space...
zachvaldez,

> can you show me some examples that can be done in this space
It'd probably be more useful if you gave me some ide of what you want to do rather than me just tossing out possibilities.  That aside, here are a couple of examples.

    'Flag all items with a red flag (Outlook 2003)
    olkItem.FlagIcon = olRedFlagIcon
    olkitem.Save

    'Set the category
    olkItem.Categories = "My Category"
    olkItem.Save

    'Print the item
    olkItem.PrintOut
say, save the attachment if any of an item in the inbox toi"C:\Temp". is this possible?
Sure.

    If olkItem.Attachments.Count > 0 Then
        For Each olkAttachment In olkItem.Attachments
            olkAttachment.SaveAsFile "C:\Temp\" & olkAttachment.FileName
        Next
    End If
Set olkInbox = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items>>> it is ot hitting the inbox that I want to read...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is what Im trying to do... I have my own inbox(personal) but I have also access to a public folder named "Union"-This is the inbox I would like to read not my personal inbox.
I would like to initiate this from an Access application. Ive seen a code from outlookcode.com but only if you selected the item you want to save in your hard dreive.
It made use of if I remember .activeexplore and .selection. But that is not what i want. I want the flexibility of reading all the email with attachment and strip attachment and save to a file folder...
Blue. that was outstanding thanks for the guy who provided the code. it is outstanding as well.
Is there a way to filter duplicates when it saves to the hard drive.
somewhere here maybe..

  If olkItem.Attachments.Count > 0 Then
        For Each olkAttachment In olkItem.Attachments
            olkAttachment.SaveAsFile "C:\Temp\" & olkAttachment.FileName
        Next
    End If
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Bkue.. what iss it doing here. reading it , it looks like it would add the label " copy 1 of attachment abc1112...." for duplicates
Is it possible for the routine to just ignore if it sees that it is a duplicate and not write the file. My reason is that I would like to import all the files saved in that directory and if they are all excel files, i do not need to import duplicate files to my access database?

One more if is not that too difficult too. Is it possible to strip the attachment from Outlook before or after it saves in he folder.


  Do While True
                If objFSO.FileExists(strRootFolderPath & strFilename) Then
                    intCount = intCount + 1
                    strFilename = "Copy (" & intCount & ") of " & olkAttachment.FileName
                Else
                    Exit Do
                End If
            Loop
            olkAttachment.SaveAsFile strRootFolderPath & strFilename
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Blue..
   If Not objFSO.FileExists(strRootFolderPath & strFilename) Then
                olkAttachment.SaveAsFile strRootFolderPath & strFilename
            End If>>>>>>>>>> should this be an Else instead
            olkAttachment.Delete >>> what did it delete here?

Also after stripping the excel file attachment, will it save the outlook item again with no attachment because it was already removed?
Yes.
Blue..
Which did you answer from my last question? thanks
Sorry, I was answering the last question "will it save the outlook item again with no attachment because it was already removed".  I hadn't noticed the other questions.  No, it shouldn't be an Else.  The attachment should be deleted either after it's saved or if a file with the same name already exists in the folder.  "What did it delete here?"  It deleted the attachment.
Great! Now I want to load all the excel files I extracted to an access table.
the excel file has same format  
Sorry, I'm not as good with Excel.  I recommend a separate question dealing with that issue.
Thanks! I got it now..