msoutlook.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How can I declare an object to match all items in my inbox?

 
Post new topic   Reply to topic    msoutlook.org Forum Index -> MS Office Outlook
Author Message
landau



Joined: 06 Feb 2008
Posts: 12

PostPosted: Tue Feb 12, 2008 2:18 pm    Post subject: How can I declare an object to match all items in my inbox? Reply with quote

I have a pretty good routine to move mail items in my Inbox to an
Archive folder. I do this by declaring a mailItem and I use its MOVE
method.

I found that not all items in the inbox are mailItems though. Some
are meeting responses (example: some are of class: olMail and some are
olMeetingResponsePositive) . How can I declare an object to cover
all possible items in my inbox, and still have access to their "move
method" ?

Thanks
-Ed

Archived from group: microsoft>public>office>developer>outlook>vba
Back to top
View user's profile Send private message
JP



Joined: 21 Nov 2007
Posts: 33

PostPosted: Tue Feb 12, 2008 3:06 pm    Post subject: Re: How can I declare an object to match all items in my inb Reply with quote

Why not just use an If statement to limit the action to mail items
only?

Dim olNS As Outlook.NameSpace
Dim olInbox As Outlook.MAPIFolder
Dim X as Object

Set olNS = GetNamespace("MAPI")
Set olInbox = olNS.GetDefaultFolder(olFolderInbox)

For Each X In olInbox.Items
If TypeOf X Is Outlook.MailItem Then
' your code for mailitems here
End If
Next X


HTH,
JP

On Feb 12, 12:18 pm, lan...@skiz.net wrote:
> I have a pretty good routine to move mail items in my Inbox to an
> Archive folder.  I do this by declaring a mailItem and I use its MOVE
> method.
>
> I found that not all items in the inbox are mailItems though.  Some
> are meeting responses (example: some are of class: olMail and some are
> olMeetingResponsePositive) .   How can I declare an object to cover
> all possible items in my inbox, and still have access to their "move
> method" ?
>
> Thanks
> -Ed
Back to top
View user's profile Send private message
landau



Joined: 06 Feb 2008
Posts: 12

PostPosted: Tue Feb 12, 2008 3:46 pm    Post subject: Re: How can I declare an object to match all items in my inb Reply with quote

I'm using the SelectionChange event of the current explorer to move
the explorer.selection (which would be an olMail or anything else).
And I *DO* want to move over the meeting replies... I want to be able
to move anything in my inbox.

So basically, in the event handler, I need to process the selected
item (explorer.selection). Ideally, I could do this:
myOlExplorer.selection.move Smile

-Ed
Back to top
View user's profile Send private message
JP



Joined: 21 Nov 2007
Posts: 33

PostPosted: Tue Feb 12, 2008 4:50 pm    Post subject: Re: How can I declare an object to match all items in my inb Reply with quote

Gotcha. The move method is supported by

ContactItem
MailItem
JournalItem
NoteItem
PostItem
TaskItem
AppointmentItem

You would probably declare your variable as an Object to cover all of
these possibilities.

(Check out http://msdn2.microsoft.com/en-us/library/aa221877.aspx)

HTH,
JP

On Feb 12, 1:46 pm, lan...@skiz.net wrote:
> I'm using the SelectionChange event of the current explorer to move
> the explorer.selection (which would be an olMail or anything else).
> And I *DO* want to move over the meeting replies... I want to be able
> to move anything in my inbox.
>
> So basically, in the event handler, I need to process the selected
> item (explorer.selection).  Ideally, I could do this:
> myOlExplorer.selection.move Smile
>
> -Ed
Back to top
View user's profile Send private message
landau



Joined: 06 Feb 2008
Posts: 12

PostPosted: Tue Feb 12, 2008 6:22 pm    Post subject: Re: How can I declare an object to match all items in my inb Reply with quote

Good idea. I set my object to type Object (insteal of
Outlook.mailItem) and I don't get type missmatches anymore, but I
still can't process all the entries in my inbox since meeting resonses
are not of type olMail. For example, at a breakpoint, my myOlMail is
pointing to an object (current selection in the explorer) which is of
type "olMeetingResponseNegative".

Should I just assume that any item in the inbox has a move method and
not even check what type is it?

This is the code I use in my event handler:

Set objMail = myOlExplorer.Selection.Item(1)
If (objMail.Class = olMail) Then 'Maybe I should get this of this
check.
If (objMail.FlagRequest = "") Then
If (Not myCurrentMail Is Nothing) Then 'myCurrentMail was
set on the last event.
myCurrentMail.Move objArchiveFolder
End If
End If
End If

Thanks
-Ed
Back to top
View user's profile Send private message
Ken Slovak - [MVP - Outlo



Joined: 12 Aug 2007
Posts: 405

PostPosted: Wed Feb 13, 2008 2:47 pm    Post subject: Re: How can I declare an object to match all items in my inb Reply with quote

You know what they say about assuming?

Check each Object.Class to see if it's a class of item you want to handle.
You can set up a Case block for that, handling each type that supports Move
and that you're prepared to work with.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


wrote in message @c4g2000hsg.googlegroups.com...
> Good idea. I set my object to type Object (insteal of
> Outlook.mailItem) and I don't get type missmatches anymore, but I
> still can't process all the entries in my inbox since meeting resonses
> are not of type olMail. For example, at a breakpoint, my myOlMail is
> pointing to an object (current selection in the explorer) which is of
> type "olMeetingResponseNegative".
>
> Should I just assume that any item in the inbox has a move method and
> not even check what type is it?
>
> This is the code I use in my event handler:
>
> Set objMail = myOlExplorer.Selection.Item(1)
> If (objMail.Class = olMail) Then 'Maybe I should get this of this
> check.
> If (objMail.FlagRequest = "") Then
> If (Not myCurrentMail Is Nothing) Then 'myCurrentMail was
> set on the last event.
> myCurrentMail.Move objArchiveFolder
> End If
> End If
> End If
>
> Thanks
> -Ed
Back to top
View user's profile Send private message
JP



Joined: 21 Nov 2007
Posts: 33

PostPosted: Wed Feb 13, 2008 10:36 pm    Post subject: Re: How can I declare an object to match all items in my inb Reply with quote

After further review, and I might be wrong about this, but wouldn't
moving all of these different objects to a mail folder turn them into
mail items?

ps- Meeting Responses might not support the .move method. Once you
read them, they update your calendar and should be safe to delete.

--JP

On Feb 12, 4:22 pm, lan...@skiz.net wrote:
> Good idea. I set my object to type Object (insteal of
> Outlook.mailItem) and I don't get type missmatches anymore, but I
> still can't process all the entries in my inbox since meeting resonses
> are not of type olMail.  For example, at a breakpoint, my myOlMail is
> pointing to an object (current selection in the explorer) which is of
> type "olMeetingResponseNegative".
>
> Should I just assume that any item in the inbox has a move method and
> not even check what type is it?
>
> This is the code I use in my event handler:
>
>  Set objMail = myOlExplorer.Selection.Item(1)
>  If (objMail.Class = olMail) Then  'Maybe I should get this of this
> check.
>      If (objMail.FlagRequest = "") Then
>          If (Not myCurrentMail Is Nothing) Then   'myCurrentMail was
> set on the last event.
>              myCurrentMail.Move objArchiveFolder
>          End If
>      End If
>  End If
>
> Thanks
> -Ed

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Reply to a MailItem object Hi everyone, Does anyone know how we can determine whether a MailItem has been replied or transferred ? Indeed, when a user replies to a MailItem, the latter generates a Reply event and a Change event on the MailItem. It seems that a Mail

"Completed" for a MailItem object I would like to retrieve/set the "Completed" property on a MailItem object. I can't find where these follow up properties are... Thanks in advance. --

The operation cannot be performed because the object has bee I am using XLS to send mail. I am using Set OutApp = logic to create a new mail and send it over outlook. But i am facing a very weird error. I am not able to replicate this error on all the machines. When i click the b

SendReceive in Outlook Object Model Do you know what method in the outlook object model will allow me to send/receive mail on a specific account?

Microsoft Outlook Object Library Hi, I am trying to use “Microsoft Outlook Object Library”. I have found a site, which mentions same. when I try to run the code given in above site I am getting annoying message saying "A program is trying to acc
Post new topic   Reply to topic    msoutlook.org Forum Index -> MS Office Outlook All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group