Solved

Extracting messages from outlook

Posted on 2006-11-06
10
282 Views
Last Modified: 2008-01-09
I have an application that copies files from a user's outlook inbox the user's desktop.  It works great. however, If I run the application again it extracts the same messages again.  How can I tell if I have already extracted a certain message from the inbox already??

0
Comment
Question by:OFGemini
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
10 Comments
 
LVL 4

Expert Comment

by:MikeSel
ID: 17920838
When you have processed a mail item, why not set a userproperty something like this

Set myUserProperty = myItem.UserProperties _
    .Add("Saved2Desktop", True)


Then add something like

If Item.UserProperties.Find("Saved2Desktop") = True Then
    Exit Sub
End If
0
 

Author Comment

by:OFGemini
ID: 18028924
What if I can't write anything to the userProperties??
0
 
LVL 4

Expert Comment

by:MikeSel
ID: 18029368
Then the only other way would be to store each item's unique id in some sort of file..


I am out on site atm so cant really work any code out..


I will try an do it when I get back!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:OFGemini
ID: 18077455
MikeSel Have you gotten a chance to work any code out?
0
 
LVL 4

Expert Comment

by:MikeSel
ID: 18077507
Can you upload your code?
That way I can try and 'work it' in
0
 

Author Comment

by:OFGemini
ID: 18077911
   Private Sub Export()


        Dim objOL As Outlook.Application
        Dim objNS As Outlook.NameSpace
        Dim olfolder As Outlook.MAPIFolder = Nothing
        Dim myItems As Outlook.Items
        Dim x As Int16
        Dim strFilePath As String = ""

        Try




            objOL = New Outlook.Application()
            objNS = objOL.GetNamespace("MAPI")
            olfolder = objOL.GetNamespace("MAPI").PickFolder


            If olfolder Is Nothing Then
                Exit Sub
            End If


            Dim fd As New FolderBrowserDialog

            If fd.ShowDialog = Windows.Forms.DialogResult.OK Then
                strFilePath = fd.SelectedPath
            Else
                Exit Sub
            End If

            myItems = olfolder.Items

            Dim sClassComp = "IPM.Note"


            For x = 1 To myItems.Count
                If myItems.Item(x).messageclass = sClassComp Then
                    Dim myMail As Outlook.MailItem = myItems(x)

                    Dim strFileName = Nothing

                    If myMail.Subject = "" Then
                        strFileName = "Untitled.msg"
                    Else
                        strFileName = myMail.Subject.Replace(":", "") & ".msg"
                    End If

                    myMail.SaveAs(System.IO.Path.Combine(strFilePath, strFileName), 3)
                End If

            Next x

        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            objOL = Nothing
            objNS = Nothing
            olfolder = Nothing
        End Try



    End Sub
0
 
LVL 4

Accepted Solution

by:
MikeSel earned 500 total points
ID: 18078019
Will it not work on userProperties then?? as this way we will need to write the id's to a table in a db. An search them each time you do the export?
0
 
LVL 4

Expert Comment

by:MikeSel
ID: 18290980
You would need to save the item as well...

Set myUserProperty = myItem.UserProperties _
    .Add("Saved2Desktop", True)
myItem.save

Is this why you couldn't save to userproperties..


   Private Sub Export()

        Dim myUserProperty as UserProperty

        Dim objOL As Outlook.Application
        Dim objNS As Outlook.NameSpace
        Dim olfolder As Outlook.MAPIFolder = Nothing
        Dim myItems As Outlook.Items
        Dim x As Int16
        Dim strFilePath As String = ""

        Try




            objOL = New Outlook.Application()
            objNS = objOL.GetNamespace("MAPI")
            olfolder = objOL.GetNamespace("MAPI").PickFolder


            If olfolder Is Nothing Then
                Exit Sub
            End If


            Dim fd As New FolderBrowserDialog

            If fd.ShowDialog = Windows.Forms.DialogResult.OK Then
                strFilePath = fd.SelectedPath
            Else
                Exit Sub
            End If

            myItems = olfolder.Items

            Dim sClassComp = "IPM.Note"


            For x = 1 To myItems.Count
                If myItems.Item(x).messageclass = sClassComp Then
                    Dim myMail As Outlook.MailItem = myItems(x)

                    Dim strFileName = Nothing

                    If myMail.Subject = "" Then
                        strFileName = "Untitled.msg"
                    Else
                        strFileName = myMail.Subject.Replace(":", "") & ".msg"
                    End If

                    myMail.SaveAs(System.IO.Path.Combine(strFilePath, strFileName), 3)
                End If

Set myUserProperty = myMail.UserProperties _
    .Add("Saved2Desktop", True)
myMail.save


            Next x

        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            objOL = Nothing
            objNS = Nothing
            olfolder = Nothing
        End Try



    End Sub
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
A short article about problems I had with the new location API and permissions in Marshmallow
Simple Linear Regression
Starting up a Project

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question