Setting Inbox to process mail items 
Author Message
 Setting Inbox to process mail items

I'm a newbie with what must be a simplistic question.  How
do I set olInboxItems to the Inbox folder collection?  I'm
trying to run my SaveFiles method everytime an email
arrives in the Inbox.  However, I'm getting a compile
error that it can't find an object when I try to set the
olInboxItems in the ExtractAttachements procedure.  I'm
really lost here.  Thanks for any assistance/guidance.

Option Explicit

Quote:

>> Private WithEvents olInboxItems As MailItem

>> Dim OutlookApp As Outlook.Application
>> Dim MynameSpace As NameSpace
>> Dim FolderList As Outlook.MAPIFolder
>> Dim strAddressNumber As String

>> Public Sub SaveFiles(Mail as MailItem)

>>      '  Do some processing

>> End Sub

>> Sub ExtractAttachments()

>> Dim flist As Outlook.MAPIFolder

>>     Set OutlookApp = GetObject(, "Outlook.Application")
>>     Set MynameSpace = OutlookApp.GetNamespace("MAPI")
>>     Set FolderList = MynameSpace.GetDefaultFolder
>> (olFolderInbox)
>>     Set FolderList = FolderList.Folders.Item("Inbox")
>>     Call SaveFiles(FolderList)

>> End Sub

>> Private Sub Application_Startup()

>>     Call ExtractAttachments

>> End Sub

>> Private Sub Application_Quit()

>>   Set olInboxItems = Nothing

>> End Sub

>> Private Sub olInboxItems_ItemAdd(ByVal Item As MailItem)


>> Item.Attachments.Count > 0 Then
>>         Item.Move (FolderList.Folders.Item("Test"))
>>         Call SaveFiles(FolderList)
>>     End If

>> End Sub



Wed, 18 May 2005 02:22:42 GMT  
 Setting Inbox to process mail items
Use this code :

Note : Item.sendername will display only the sendername...and not the email

to Greg Busby.

Regards
Natarajan

Option Explicit
 Dim OutlookApp As Outlook.Application
 Dim MynameSpace As NameSpace
 Dim FolderList As Outlook.MAPIFolder
 Public WithEvents myOlInboxItems As Outlook.Items

 Public Sub SaveFiles(Mail As MailItem)

      '  Do some processing

 End Sub

 Sub ExtractAttachments()
     Set OutlookApp = GetObject(, "Outlook.Application")
     Set MynameSpace = OutlookApp.GetNamespace("MAPI")
     Set FolderList = MynameSpace.GetDefaultFolder(olFolderInbox)
     Set myOlInboxItems = FolderList.Items
 End Sub

 Private Sub Application_Startup()

     Call ExtractAttachments

 End Sub

 Private Sub Application_Quit()

   Set myOlInboxItems = Nothing

 End Sub

 Private Sub myolInboxItems_ItemAdd(ByVal Item As Object)
 MsgBox Item.SenderName
     If Item.SenderName = "Greg Busby" And Item.Attachments.Count > 0 Then
         Item.Move (FolderList.Folders.Item("Test"))
         Call SaveFiles(FolderList)
     End If

 End Sub


Quote:
> I'm a newbie with what must be a simplistic question.  How
> do I set olInboxItems to the Inbox folder collection?  I'm
> trying to run my SaveFiles method everytime an email
> arrives in the Inbox.  However, I'm getting a compile
> error that it can't find an object when I try to set the
> olInboxItems in the ExtractAttachements procedure.  I'm
> really lost here.  Thanks for any assistance/guidance.

> Option Explicit

> >> Private WithEvents olInboxItems As MailItem

> >> Dim OutlookApp As Outlook.Application
> >> Dim MynameSpace As NameSpace
> >> Dim FolderList As Outlook.MAPIFolder
> >> Dim strAddressNumber As String

> >> Public Sub SaveFiles(Mail as MailItem)

> >>      '  Do some processing

> >> End Sub

> >> Sub ExtractAttachments()

> >> Dim flist As Outlook.MAPIFolder

> >>     Set OutlookApp = GetObject(, "Outlook.Application")
> >>     Set MynameSpace = OutlookApp.GetNamespace("MAPI")
> >>     Set FolderList = MynameSpace.GetDefaultFolder
> >> (olFolderInbox)
> >>     Set FolderList = FolderList.Folders.Item("Inbox")
> >>     Call SaveFiles(FolderList)

> >> End Sub

> >> Private Sub Application_Startup()

> >>     Call ExtractAttachments

> >> End Sub

> >> Private Sub Application_Quit()

> >>   Set olInboxItems = Nothing

> >> End Sub

> >> Private Sub olInboxItems_ItemAdd(ByVal Item As MailItem)


> >> Item.Attachments.Count > 0 Then
> >>         Item.Move (FolderList.Folders.Item("Test"))
> >>         Call SaveFiles(FolderList)
> >>     End If

> >> End Sub



Fri, 20 May 2005 01:49:05 GMT  
 Setting Inbox to process mail items
Thanks for the assistance.  I'll give it a try.

Quote:
>-----Original Message-----
>Use this code :

>Note : Item.sendername will display only the

sendername...and not the email
request youto change it
Quote:
>to Greg Busby.

>Regards
>Natarajan

>Option Explicit
> Dim OutlookApp As Outlook.Application
> Dim MynameSpace As NameSpace
> Dim FolderList As Outlook.MAPIFolder
> Public WithEvents myOlInboxItems As Outlook.Items

> Public Sub SaveFiles(Mail As MailItem)

>      '  Do some processing

> End Sub

> Sub ExtractAttachments()
>     Set OutlookApp = GetObject(, "Outlook.Application")
>     Set MynameSpace = OutlookApp.GetNamespace("MAPI")
>     Set FolderList = MynameSpace.GetDefaultFolder
(olFolderInbox)
>     Set myOlInboxItems = FolderList.Items
> End Sub

> Private Sub Application_Startup()

>     Call ExtractAttachments

> End Sub

> Private Sub Application_Quit()

>   Set myOlInboxItems = Nothing

> End Sub

> Private Sub myolInboxItems_ItemAdd(ByVal Item As Object)
> MsgBox Item.SenderName
>     If Item.SenderName = "Greg Busby" And

Item.Attachments.Count > 0 Then

- Show quoted text -

Quote:
>         Item.Move (FolderList.Folders.Item("Test"))
>         Call SaveFiles(FolderList)
>     End If

> End Sub



>> I'm a newbie with what must be a simplistic question.  
How
>> do I set olInboxItems to the Inbox folder collection?  
I'm
>> trying to run my SaveFiles method everytime an email
>> arrives in the Inbox.  However, I'm getting a compile
>> error that it can't find an object when I try to set the
>> olInboxItems in the ExtractAttachements procedure.  I'm
>> really lost here.  Thanks for any assistance/guidance.

>> Option Explicit

>> >> Private WithEvents olInboxItems As MailItem

>> >> Dim OutlookApp As Outlook.Application
>> >> Dim MynameSpace As NameSpace
>> >> Dim FolderList As Outlook.MAPIFolder
>> >> Dim strAddressNumber As String

>> >> Public Sub SaveFiles(Mail as MailItem)

>> >>      '  Do some processing

>> >> End Sub

>> >> Sub ExtractAttachments()

>> >> Dim flist As Outlook.MAPIFolder

>> >>     Set OutlookApp = GetObject

(, "Outlook.Application")

- Show quoted text -

Quote:
>> >>     Set MynameSpace = OutlookApp.GetNamespace("MAPI")
>> >>     Set FolderList = MynameSpace.GetDefaultFolder
>> >> (olFolderInbox)
>> >>     Set FolderList = FolderList.Folders.Item("Inbox")
>> >>     Call SaveFiles(FolderList)

>> >> End Sub

>> >> Private Sub Application_Startup()

>> >>     Call ExtractAttachments

>> >> End Sub

>> >> Private Sub Application_Quit()

>> >>   Set olInboxItems = Nothing

>> >> End Sub

>> >> Private Sub olInboxItems_ItemAdd(ByVal Item As
MailItem)


>> >> Item.Attachments.Count > 0 Then
>> >>         Item.Move (FolderList.Folders.Item("Test"))
>> >>         Call SaveFiles(FolderList)
>> >>     End If

>> >> End Sub

>.



Sat, 21 May 2005 09:41:06 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Missed New Mail/Inbox Items Add Events

2. Outlook97 - Access97 Reading Mail Items in inbox

3. Processing Selected Mail Items

4. Help with processing inbox emails

5. Inbox right click menu item

6. Where are saved the rules of inbox items in outlook

7. Changing display font of Inbox item

8. Permanently delete item from Inbox in Outlook VBA

9. Problem with REPORT.IPM.Note.IPNRN items when Iterating Through Inbox

10. Get Currently Selected Inbox Item

11. How do i find all items from a person in inbox by code

12. Extracting the Internet Email Address from Inbox Items

 

 
Powered by phpBB® Forum Software