A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

MailItem from an RSS feed



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 3rd 09, 01:38 AM posted to microsoft.public.outlook.program_vba
Dan
external usenet poster
 
Posts: 166
Default MailItem from an RSS feed

I am using Outlook 2007 and VB6. I am using Outlook Automation in a VB
program to choose certain Outlook messages from a folder called Archive, save
them as MSG files, and then delete the messages. It works fine when only
email messages are in the folder.

But occasionally I subscribe to RSS feeds, and sometimes I drag the messages
from the RSS feeds to the Archive folder. I have to skip over those because I
can't treat them as MailItem objects.

Here is a simplified view of the code I'm using:

Dim DateTimeStr As String
Dim FilterStr As String
Dim Message As Outlook.MailItem
Dim MessageFolder As Object
Dim MessageList As Object
Dim ObjItem As Object
Dim OutlookApp As Object
Dim OutlookNamespace As Object
Dim SelectedOutlookFolder as Outlook.Folder

Set OutlookApp = GetObject(, "Outlook.Application")
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set MessageFolder =
OutlookNamespace.GetFolderFromID(SelectedOutlookFo lder.EntryID,
SelectedOutlookFolder.StoreID)

DateTimeStr = Format("7/1/2009 12:00am", "ddddd h:nn AMPM")
FilterStr = "[SentOn] '" & DateTimeStr & "'"
Set MessageList = MessageFolder.Items.Restrict(FilterStr)

If Not MessageList Is Nothing Then
For Each ObjItem In MessageList
Set Message = Nothing
On Error Resume Next
Set Message = ObjItem
If Not Message Is Nothing Then
End If
Next ObjItem
End If

Is there any way that I can test for the RSS feed messages in this same loop
and save them as MSG files also? Thanks for your help.
Ads
  #2  
Old July 3rd 09, 02:46 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default MailItem from an RSS feed

This is the problem statement:

Dim Message As Outlook.MailItem

It makes an assumption that all items being processed are MailItem objects.
If you use Object instead of MailItem for the declaration, your code should
still work fine.

Also, you should not delete messages inside a For Each ... Next loop.
Instead, use a down-counting loop, e.g.:

Dim ObjItem As Object
count = MessageList.Count
For i = count to 1 Step -1
Set ObjItem = MessageList(i)
ObjItem.SaveAs "some path", olMSG
ObjItem.Delete
Next

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Dan" wrote in message
...
I am using Outlook 2007 and VB6. I am using Outlook Automation in a VB
program to choose certain Outlook messages from a folder called Archive,
save
them as MSG files, and then delete the messages. It works fine when only
email messages are in the folder.

But occasionally I subscribe to RSS feeds, and sometimes I drag the
messages
from the RSS feeds to the Archive folder. I have to skip over those
because I
can't treat them as MailItem objects.

Here is a simplified view of the code I'm using:

Dim DateTimeStr As String
Dim FilterStr As String
Dim Message As Outlook.MailItem
Dim MessageFolder As Object
Dim MessageList As Object
Dim ObjItem As Object
Dim OutlookApp As Object
Dim OutlookNamespace As Object
Dim SelectedOutlookFolder as Outlook.Folder

Set OutlookApp = GetObject(, "Outlook.Application")
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set MessageFolder =
OutlookNamespace.GetFolderFromID(SelectedOutlookFo lder.EntryID,
SelectedOutlookFolder.StoreID)

DateTimeStr = Format("7/1/2009 12:00am", "ddddd h:nn AMPM")
FilterStr = "[SentOn] '" & DateTimeStr & "'"
Set MessageList = MessageFolder.Items.Restrict(FilterStr)

If Not MessageList Is Nothing Then
For Each ObjItem In MessageList
Set Message = Nothing
On Error Resume Next
Set Message = ObjItem
If Not Message Is Nothing Then
End If
Next ObjItem
End If

Is there any way that I can test for the RSS feed messages in this same
loop
and save them as MSG files also? Thanks for your help.




  #3  
Old July 3rd 09, 03:43 AM posted to microsoft.public.outlook.program_vba
Dan
external usenet poster
 
Posts: 166
Default MailItem from an RSS feed

Sue,

Thank you. You solved my problem.

Dan

"Sue Mosher [MVP]" wrote:

This is the problem statement:

Dim Message As Outlook.MailItem

It makes an assumption that all items being processed are MailItem objects.
If you use Object instead of MailItem for the declaration, your code should
still work fine.

Also, you should not delete messages inside a For Each ... Next loop.
Instead, use a down-counting loop, e.g.:

Dim ObjItem As Object
count = MessageList.Count
For i = count to 1 Step -1
Set ObjItem = MessageList(i)
ObjItem.SaveAs "some path", olMSG
ObjItem.Delete
Next

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Dan" wrote in message
...
I am using Outlook 2007 and VB6. I am using Outlook Automation in a VB
program to choose certain Outlook messages from a folder called Archive,
save
them as MSG files, and then delete the messages. It works fine when only
email messages are in the folder.

But occasionally I subscribe to RSS feeds, and sometimes I drag the
messages
from the RSS feeds to the Archive folder. I have to skip over those
because I
can't treat them as MailItem objects.

Here is a simplified view of the code I'm using:

Dim DateTimeStr As String
Dim FilterStr As String
Dim Message As Outlook.MailItem
Dim MessageFolder As Object
Dim MessageList As Object
Dim ObjItem As Object
Dim OutlookApp As Object
Dim OutlookNamespace As Object
Dim SelectedOutlookFolder as Outlook.Folder

Set OutlookApp = GetObject(, "Outlook.Application")
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set MessageFolder =
OutlookNamespace.GetFolderFromID(SelectedOutlookFo lder.EntryID,
SelectedOutlookFolder.StoreID)

DateTimeStr = Format("7/1/2009 12:00am", "ddddd h:nn AMPM")
FilterStr = "[SentOn] '" & DateTimeStr & "'"
Set MessageList = MessageFolder.Items.Restrict(FilterStr)

If Not MessageList Is Nothing Then
For Each ObjItem In MessageList
Set Message = Nothing
On Error Resume Next
Set Message = ObjItem
If Not Message Is Nothing Then
End If
Next ObjItem
End If

Is there any way that I can test for the RSS feed messages in this same
loop
and save them as MSG files also? Thanks for your help.





 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get an RSS feed from Craigslist???? [email protected] Outlook - General Queries 4 June 9th 08 04:30 AM
Add a RSS feed in Outlook Bickers Add-ins for Outlook 2 March 12th 07 09:55 AM
RSS feed Tim Scott Mathews Outlook - General Queries 0 February 22nd 07 11:33 AM
RSS feed Rodders Outlook Express 1 December 29th 06 11:20 PM
How can I create a MailItem that displays like a received MailItem ? Clive Outlook - Using Forms 0 February 27th 06 04:14 PM


All times are GMT +1. The time now is 08:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.