Solved

Extracting messages from outlook

Posted on 2006-11-06
10
277 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
Comment Utility
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
Comment Utility
What if I can't write anything to the userProperties??
0
 
LVL 4

Expert Comment

by:MikeSel
Comment Utility
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
Comment Utility
MikeSel Have you gotten a chance to work any code out?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 4

Expert Comment

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

Author Comment

by:OFGemini
Comment Utility
   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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

763 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

6 Experts available now in Live!

Get 1:1 Help Now