Finding an inbox email question

Status
Not open for further replies.
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
 

Odilon

Member
change :




SFILTER = "[Subject] = " & Chr(34) & Trim(ZfindZ) & Chr(34)


Set objMessage = objFolder.Items.Find(SFILTER)




-----------------------------




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
 
T

Thor (Hammer of God)

Changing " to Chr(34) doesn't make any difference. However, it probably *is*

easier to code and read then the """ bit.

"Odilon" wrote:



> change :

> SFILTER = "[Subject] = " & Chr(34) & Trim(ZfindZ) & Chr(34)
> Set objMessage = objFolder.Items.Find(SFILTER)

> ---------------------------
> Salad;118512 Wrote:
> > 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


> > Odilon
>

> .
>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
bhamberg Finding a rouge rule... Using Outlook 6
K Outlook.com is not showing, or finding via search, all my Contacts (People) Using Outlook 0
A ScanPST finding errors but no Repair button Using Outlook 2
F Finding Meetings/Tasks in a date range Using Outlook 1
M Finding Tasks in Outlook 365 Using Outlook 1
A "search people" not finding all contacts Using Outlook 17
Commodore Finding items from last 7 days Using Outlook 2
T Need help with finding/updating task Outlook VBA and Custom Forms 1
M Finding a folder by name Outlook 2013 Using Outlook 4
S Finding Distribution List Name Outlook VBA and Custom Forms 3
Ron Kirschner Finding a rule Using Outlook 1
A OL13 Calendar Search not finding most items Using Outlook 15
L Finding deleted contact from shared folder. Exchange Server Administration 1
G finding Outlook 2010 pst in Windows XP Using Outlook 2
P finding a folder containing an email item Using Outlook 0
C Finding an email address based on a name Outlook VBA and Custom Forms 7
N Finding messages by conversation macro Outlook VBA and Custom Forms 1
M Outlook VBA Form not finding FOR LOOP -- Error message Outlook VBA and Custom Forms 2
J How to create a drop down user defined field that will appear on an inbox view Outlook VBA and Custom Forms 8
P Emails assigned with a certain category (within a shared inbox) to be copied to a specific folder. Outlook VBA and Custom Forms 2
O Moving "tasks" to inbox in Outlook 2016 Using Outlook 1
A Imap account not auto syncing inbox at startup Using Outlook 0
S Outlook 2016 dont delete inbox item Using Outlook 0
F Jump to Inbox folder when click on Favorite Using Outlook 8
R Moved 6 months worth (approx 1500 emails) lost from moving from TPG inbox to Icloud inbox (folders) Using Outlook 3
S Problem Checking the available stores in my Inbox (Outlook VBA) Outlook VBA and Custom Forms 0
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
A Inbox didn't got read Outlook VBA and Custom Forms 0
A Unflag Inbox and Flag Inbox with Orange Category After Item is send Outlook VBA and Custom Forms 3
glnz O365 - How to combine the Inboxes for four email accounts into a single Inbox Using Outlook 7
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
G Inbox shows old email Using Outlook 3
C Configuring Inbox columns Using Outlook 2
D Inbox column color coding Using Outlook 2
R Outlook 2010 How do you export 2 email Accounts' 2010 Inbox Files to new computer (2019)? Using Outlook 0
J Collaborative Inbox Using Outlook 1
M Missing emails in Inbox, but are present in webmail Using Outlook 0
R List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email Outlook VBA and Custom Forms 1
H Upon opening Outlook, make my popmail inbox open instead of outlook.com inbox Using Outlook 1
P Outlook Mobile App Doesn't Refresh Inbox Using Outlook 0
H In outlook 365 POP mail Inbox, email takes a long time or never arrives. Using Outlook 1
K No emails in inbox Using Outlook.com accounts in Outlook 1
D Unopened message in inbox deleted and not in deleted items Using Outlook 3
R Exporting recovered Deleted Items outside the Inbox Using Outlook 1
N Focussed Inbox Rules Failing Using Outlook 5
M Inbox not showing to deliver new email to this account Using Outlook 3
mctabish Setting "Reply To" based on inbox Outlook VBA and Custom Forms 2
T Inbox Sub-Folder - Web Using Outlook 1
P Two main Outlook gripes: Voting buttons not working externally nor Focused Inbox Using Outlook 1

Similar threads

Top