S
Salad
I've spent awhile looking for a way to find an email on the web and
google groups. I'm not having very much luck, probably am not entering
the correct keywords.
I know the following values:
From 'joeblow
Subject 'test message
MessageSize '6058
ReceivedTime '1/11/2009 10:00:10 AM
LastModificationTime '1/25/2010 2:53:17 PM
CreationTime '11/11/2009 10:59:04 AM
My goal is to find the email, see if it has any attachments, and if so,
be able to save them. I think I could do that if I could find the
message...but I'm lost. Could you look at the following code and tell
me if I need to set another object or if I'm using the Find method
incorrectly? What properties are best to search on?
Public Sub FindMailItems()
Dim objApp As Object
Dim objSession As Object
Dim objFolder As Object
Dim objFolderColl As Object
Dim objItemCollection As Object
Const FOLDER_INBOX = 6
Set objApp = CreateObject("Outlook.Application")
Set objSession = objApp.GetNamespace("Mapi")
Set objFolder = objSession.GetDefaultFolder(FOLDER_INBOX)
Set objItemCollection = objFolder.Items
'this is where I'm going wrong
Set objMessage = objFolder.Items.Find("[Subject] = ""This is the
subject line""")
Set objItemCollection = Nothing
Set objFolder = Nothing
Set objSession = Nothing
Set objApp = Nothing
MsgBox "Done"
End Sub
google groups. I'm not having very much luck, probably am not entering
the correct keywords.
I know the following values:
From 'joeblow
Subject 'test message
MessageSize '6058
ReceivedTime '1/11/2009 10:00:10 AM
LastModificationTime '1/25/2010 2:53:17 PM
CreationTime '11/11/2009 10:59:04 AM
My goal is to find the email, see if it has any attachments, and if so,
be able to save them. I think I could do that if I could find the
message...but I'm lost. Could you look at the following code and tell
me if I need to set another object or if I'm using the Find method
incorrectly? What properties are best to search on?
Public Sub FindMailItems()
Dim objApp As Object
Dim objSession As Object
Dim objFolder As Object
Dim objFolderColl As Object
Dim objItemCollection As Object
Const FOLDER_INBOX = 6
Set objApp = CreateObject("Outlook.Application")
Set objSession = objApp.GetNamespace("Mapi")
Set objFolder = objSession.GetDefaultFolder(FOLDER_INBOX)
Set objItemCollection = objFolder.Items
'this is where I'm going wrong
Set objMessage = objFolder.Items.Find("[Subject] = ""This is the
subject line""")
Set objItemCollection = Nothing
Set objFolder = Nothing
Set objSession = Nothing
Set objApp = Nothing
MsgBox "Done"
End Sub