Solved

Extracting messages from outlook

Posted on 2006-11-06
10
278 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
  • 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
 

Author Comment

by:OFGemini
ID: 18077455
MikeSel Have you gotten a chance to work any code out?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB 6.0 printer how to align 6 57
splitOdd10 challenge 5 74
Device same like our heart 12 74
When i run adoquery my application freezes 26 150
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

932 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now