Outlook items

N

Nathan Carroll

Why am I able to use this in Outlook and not do the same from .Net.
My problems centers around the Items in the xp version of below i used the
interop references. Does something similar exist for 2000?

'this works fine in ol 2000
Dim item As Object
Dim items As Outlook.items
Dim itemcount As Integer
Dim subfolder As MAPIFolder
Dim mi As MailItem

On Error Resume Next

Set items =
ThisOutlookSession.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).item
s
For Each item In items
If item.Class = olMail Then
Set mi = item
Set subfolder =
ThisOutlookSession.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox) _
.Folders(mi.SenderName)
If subfolder Is Nothing Then

ThisOutlookSession.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox) _
.Folders.Add (mi.SenderName)
Set subfolder =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox) _
.Folders(mi.SenderName)
End If
mi.Move subfolder
End If
Next





previously this had worked with an outlook xp reference following the com
example on msdn from micoreye
but I am trying to implement the addin with Outlook 2000


VB.net:
'works with the interop dlls but not when I use 9.0
Try
Dim item As Object
For Each item In Inbox
If TypeOf item Is MailItem Then
Try
Dim subfolder As MAPIFolder
Dim sm As Redemption.SafeMailItem
sm.Item = item
MessageBox.Show(sm.SenderName)
subfolder = Me.m_olNamespace.GetFolderFromID(sm.SenderName)
If subfolder Is Nothing Then
Me.m_olNamespace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders.Ad
d(sm.SenderName)
End If
CType(item, MailItem).Move(subfolder)
Catch ex As System.Exception
End Try
End If
Next
Catch ex As SystemException
DebugWriter("CleanInbox Exception: {0}", ex.Message)
End Try
 
F

Fergus Cooney

Hi Nathan,

Could you say a bit more about what the issue is? - I don't know what I'm
looking for.

Regards,
Fergus
 
N

Nathan Carroll

Fergus,
I'm trying to incorporate this
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnout2k2/ht
ml/odc_oladdinvbnet.asp but in a project that adds into a 2000 outlook. At
home I am able to get the com to work using the example link and even do the
things that I want to do with it ( My home machine software matches the
article). Now at work we have Outlook 2000; thus the interop reference to
outlook and office will not work. So I replaced them with MSO9.DLL and
msoutl9.olb. When I did that I found that this line came up with a task
error
 
N

Nathan Carroll

disregard previous.


Fergus,
I'm trying to incorporate this
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnout2k2/ht
ml/odc_oladdinvbnet.asp but in a project that adds into a 2000 outlook. At
home I am able to get the com to work using the example link and even do the
things that I want to do with it ( My home machine software matches the
article). Now at work we have Outlook 2000; thus the interop reference to
outlook and office will not work. So I replaced them with MSO9.DLL and
msoutl9.olb. When I did that I found that this line came up with a task
error
C:\VSProjects\oul3\OutAddIn.vb(172): Expression is of type 'Outlook.Items',
which is not a collection type.
from the line:

For Each item In Inbox
from :
'no problem on this one
Me.Inbox =
Me.m_olNamespace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Items
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top