Board index » Visual Studio » .Net Outlook Inbox Folder Question Getting 1st Message problem.

.Net Outlook Inbox Folder Question Getting 1st Message problem.

Visual Studio131
All,



I have some code that is executed when a "New E-mail" arrives. When

executing this code on several different machines I get either the New

Message or the Last Message. All machines are running same version of

Outlook 2003 SP1.



On one machine Visual Studio .Net is installed. On this machine I get the

last message when issuing the

molMi = molmfib.Items(1) instead of the New Message.



On the other machine I get the "New Message"...



Any explainationtions?



Here is what I am using to get the mail...



Dim molns As Outlook.NameSpace

Dim molmfib As Outlook.MAPIFolder

Dim molMi As Outlook.MailItem

Dim i As Integer

molns = m_Olapp.GetNamespace("MAPI")

molmfib =

molns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)



Visual Studio .Net PC

i = molmfib.Items.Count

molMi = molmfib.Items(i)

sSubTemp = molMi.Subject



'Other Machine Code to get New Message

molMi = molmfib.Items(1)



Thanks,



Rog


-
 

Re:.Net Outlook Inbox Folder Question Getting 1st Message problem.

Hi Roger,



The problem could be how the messages are sorted in each Outlook. One

probably puts new messages at the top while the other puts them at the

bottom. I think you would need to loop through them and pull them off based

on date or on the property that shows whether or not they were already read.

I've never worked with Outlook so I don't know what those properties are. A

quick look at the object model should tell you. Good luck! Ken.



--

Ken Dopierala Jr.

For great ASP.Net web hosting try:

http://www.webhost4life.com/default.asp?refid" rel="nofollow" target="_blank">www.webhost4life.com/default.asp=Spinlight

If you sign up under me and need help, email me.



"Roger" <davisro@netins.net>wrote in message

Quote
All,



I have some code that is executed when a "New E-mail" arrives. When

executing this code on several different machines I get either the New

Message or the Last Message. All machines are running same version of

Outlook 2003 SP1.



On one machine Visual Studio .Net is installed. On this machine I get the

last message when issuing the

molMi = molmfib.Items(1) instead of the New Message.



On the other machine I get the "New Message"...



Any explainationtions?



Here is what I am using to get the mail...



Dim molns As Outlook.NameSpace

Dim molmfib As Outlook.MAPIFolder

Dim molMi As Outlook.MailItem

Dim i As Integer

molns = m_Olapp.GetNamespace("MAPI")

molmfib =

molns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)



Visual Studio .Net PC

i = molmfib.Items.Count

molMi = molmfib.Items(i)

sSubTemp = molMi.Subject



'Other Machine Code to get New Message

molMi = molmfib.Items(1)



Thanks,



Rog









-