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

EntryID problem



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 22nd 07, 01:01 PM posted to microsoft.public.outlook.program_vba
vonClausowitz
external usenet poster
 
Posts: 29
Default EntryID problem

Hi All,

I'm trying to compare emails in two different mailboxes. Therefor I
need the SMTP address, the only way to do that is via the EntryID.
When using my code and can't seem to get into the second mailbox. I
get an MAPI_E_LOGON failure message.

Private Sub cmdInlezen2_Click()

Dim oudDatum As Date 'datum laatst gecheckte email
Dim nieuwDatum As Date 'datum oudste email in eigen folder
Dim iNumItems, iNumOwnItems As Integer
Dim iTotal As Integer
Dim i As Integer

Dim objSession As MAPI.Session
Dim objMsg As MAPI.Message
Dim objsender As MAPI.AddressEntry
Dim objItem As outlook.MailItem

Set objSession = CreateObject("MAPI.session")
objSession.Logon "", "", False, False

iNumItems = olDeleteFolder.Items.Count
iNumOwnItems = olOwnFolder.Items.Count
iTotal = iNumItems + iNumOwnItems

'bepaal de jongste en oudste email in mijn eigen folder
oudDatum = olOwnFolder.Items.Item(iNumOwnItems).ReceivedTime 'de
oudste email
nieuwDatum = olOwnFolder.Items.Item(1).ReceivedTime 'de laatst
binnengekomen email

'eigen Inbox inlezen in Listview1
For Each olmailitem In olOwnFolder.Items
If olmailitem.Class = olMail Then 'alleen echte emails
vergelijken
If olmailitem.Subject = "" Then
GoTo NoSubject
End If
Set objMsg = objSession2.GetMessage(objItem.EntryID)
Set objsender = objMsg.Sender
Set itmX = ListView1.ListItems.Add(, ,
objsender.Address, , 2)
itmX.SubItems(1) = olmailitem.Subject
itmX.SubItems(2) = olmailitem.ReceivedTime
End If
NoSubject:
Next

'Deleted Items CLASSINT inlezen in Listview2
For Each objItem In olDeleteFolder.Items
If objItem.Class = olMail Then 'alleen echte emails vergelijken
If objItem.ReceivedTime = oudDatum Then 'alleen emails die
jonger of even oud zijn
If objItem.Subject = "" Then
GoTo NoSubject2
End If
Set objMsg = objSession2.GetMessage(objItem.EntryID)
Set objsender = objMsg.Sender
Set itmX = ListView2.ListItems.Add(, ,
objsender.Address, , 2)
itmX.SubItems(1) = objItem.Subject
itmX.SubItems(2) = objItem.ReceivedTime
End If
If DateDiff("n", objItem.ReceivedTime, oudDatum) 60 Then
'er moet minimaal 60 minuten tussen zitten
'If objItem.ReceivedTime oudDatum Then 'stoppen er zijn
geen emails meer
Exit For
End If
End If
NoSubject2:
Next

End Sub

Regards
Marco

Ads
  #2  
Old August 22nd 07, 02:59 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default EntryID problem

That code is incomplete, I don't see where the second MAPI session is being
instantiated or how. That's the key to logging into a different mailbox,
that and the Logon.

You don't need an EntryID to log into a different mailbox using CDO 1.21.

--
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


"vonClausowitz" wrote in message
ps.com...
Hi All,

I'm trying to compare emails in two different mailboxes. Therefor I
need the SMTP address, the only way to do that is via the EntryID.
When using my code and can't seem to get into the second mailbox. I
get an MAPI_E_LOGON failure message.

Private Sub cmdInlezen2_Click()

Dim oudDatum As Date 'datum laatst gecheckte email
Dim nieuwDatum As Date 'datum oudste email in eigen folder
Dim iNumItems, iNumOwnItems As Integer
Dim iTotal As Integer
Dim i As Integer

Dim objSession As MAPI.Session
Dim objMsg As MAPI.Message
Dim objsender As MAPI.AddressEntry
Dim objItem As outlook.MailItem

Set objSession = CreateObject("MAPI.session")
objSession.Logon "", "", False, False

iNumItems = olDeleteFolder.Items.Count
iNumOwnItems = olOwnFolder.Items.Count
iTotal = iNumItems + iNumOwnItems

'bepaal de jongste en oudste email in mijn eigen folder
oudDatum = olOwnFolder.Items.Item(iNumOwnItems).ReceivedTime 'de
oudste email
nieuwDatum = olOwnFolder.Items.Item(1).ReceivedTime 'de laatst
binnengekomen email

'eigen Inbox inlezen in Listview1
For Each olmailitem In olOwnFolder.Items
If olmailitem.Class = olMail Then 'alleen echte emails
vergelijken
If olmailitem.Subject = "" Then
GoTo NoSubject
End If
Set objMsg = objSession2.GetMessage(objItem.EntryID)
Set objsender = objMsg.Sender
Set itmX = ListView1.ListItems.Add(, ,
objsender.Address, , 2)
itmX.SubItems(1) = olmailitem.Subject
itmX.SubItems(2) = olmailitem.ReceivedTime
End If
NoSubject:
Next

'Deleted Items CLASSINT inlezen in Listview2
For Each objItem In olDeleteFolder.Items
If objItem.Class = olMail Then 'alleen echte emails vergelijken
If objItem.ReceivedTime = oudDatum Then 'alleen emails die
jonger of even oud zijn
If objItem.Subject = "" Then
GoTo NoSubject2
End If
Set objMsg = objSession2.GetMessage(objItem.EntryID)
Set objsender = objMsg.Sender
Set itmX = ListView2.ListItems.Add(, ,
objsender.Address, , 2)
itmX.SubItems(1) = objItem.Subject
itmX.SubItems(2) = objItem.ReceivedTime
End If
If DateDiff("n", objItem.ReceivedTime, oudDatum) 60 Then
'er moet minimaal 60 minuten tussen zitten
'If objItem.ReceivedTime oudDatum Then 'stoppen er zijn
geen emails meer
Exit For
End If
End If
NoSubject2:
Next

End Sub

Regards
Marco


  #3  
Old August 22nd 07, 06:46 PM posted to microsoft.public.outlook.program_vba
vonClausowitz
external usenet poster
 
Posts: 29
Default EntryID problem

On 22 aug, 15:59, "Ken Slovak - [MVP - Outlook]"
wrote:
That code is incomplete, I don't see where the second MAPI session is being
instantiated or how. That's the key to logging into a different mailbox,
that and the Logon.

You don't need an EntryID to log into a different mailbox using CDO 1.21.

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

"vonClausowitz" wrote in message

ps.com...



Hi All,


I'm trying to compare emails in two different mailboxes. Therefor I
need the SMTP address, the only way to do that is via the EntryID.
When using my code and can't seem to get into the second mailbox. I
get an MAPI_E_LOGON failure message.


Private Sub cmdInlezen2_Click()


Dim oudDatum As Date 'datum laatst gecheckte email
Dim nieuwDatum As Date 'datum oudste email in eigen folder
Dim iNumItems, iNumOwnItems As Integer
Dim iTotal As Integer
Dim i As Integer


Dim objSession As MAPI.Session
Dim objMsg As MAPI.Message
Dim objsender As MAPI.AddressEntry
Dim objItem As outlook.MailItem


Set objSession = CreateObject("MAPI.session")
objSession.Logon "", "", False, False


iNumItems = olDeleteFolder.Items.Count
iNumOwnItems = olOwnFolder.Items.Count
iTotal = iNumItems + iNumOwnItems


'bepaal de jongste en oudste email in mijn eigen folder
oudDatum = olOwnFolder.Items.Item(iNumOwnItems).ReceivedTime 'de
oudste email
nieuwDatum = olOwnFolder.Items.Item(1).ReceivedTime 'de laatst
binnengekomen email


'eigen Inbox inlezen in Listview1
For Each olmailitem In olOwnFolder.Items
If olmailitem.Class = olMail Then 'alleen echte emails
vergelijken
If olmailitem.Subject = "" Then
GoTo NoSubject
End If
Set objMsg = objSession2.GetMessage(objItem.EntryID)
Set objsender = objMsg.Sender
Set itmX = ListView1.ListItems.Add(, ,
objsender.Address, , 2)
itmX.SubItems(1) = olmailitem.Subject
itmX.SubItems(2) = olmailitem.ReceivedTime
End If
NoSubject:
Next


'Deleted Items CLASSINT inlezen in Listview2
For Each objItem In olDeleteFolder.Items
If objItem.Class = olMail Then 'alleen echte emails vergelijken
If objItem.ReceivedTime = oudDatum Then 'alleen emails die
jonger of even oud zijn
If objItem.Subject = "" Then
GoTo NoSubject2
End If
Set objMsg = objSession2.GetMessage(objItem.EntryID)
Set objsender = objMsg.Sender
Set itmX = ListView2.ListItems.Add(, ,
objsender.Address, , 2)
itmX.SubItems(1) = objItem.Subject
itmX.SubItems(2) = objItem.ReceivedTime
End If
If DateDiff("n", objItem.ReceivedTime, oudDatum) 60 Then
'er moet minimaal 60 minuten tussen zitten
'If objItem.ReceivedTime oudDatum Then 'stoppen er zijn
geen emails meer
Exit For
End If
End If
NoSubject2:
Next


End Sub


Regards
Marco- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven -


Ken,

What am I missing then?
This is what I had before but didn't work:

strProfile = "ServerName" & vbCrlf & "MailAccount"
Set objSession2 = CreateObject("MAPI.session")
objSession2.Logon "", "", False, True,0,False,strProfile

Someone told me that you can't access two mailboxes wit CDO.

please some example.

Marco

  #4  
Old August 23rd 07, 03:31 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default EntryID problem

You have to log off the first mailbox before you log into a second mailbox
in CDO.

Why are you using CDO for this anyway? I'd be using either the Outlook
object model and GetSharedDefaultFolder or Redemption. CDO is old, passe and
not standard any more. It's not supported for managed code and is being
deprecated. It's not the way to go.

Just use GetSharedDefaultFolder with a Recipient object that you create for
whoever's mailbox you want to access.

--
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


"vonClausowitz" wrote in message
oups.com...
snip
What am I missing then?
This is what I had before but didn't work:

strProfile = "ServerName" & vbCrlf & "MailAccount"
Set objSession2 = CreateObject("MAPI.session")
objSession2.Logon "", "", False, True,0,False,strProfile

Someone told me that you can't access two mailboxes wit CDO.

please some example.

Marco


 




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
Problem in opening Outlook 2003 contact- Error Message " The properties dialog box could not be displayed. An invalid ENTRYID was pas. Jaweed Patel Outlook - Using Contacts 1 April 17th 07 01:31 PM
Problem in view Outlook 2003 contacts. Error " The properties dialog box could not be displayed. An invalid ENTRYID was pass" Jaweed Patel Outlook - Using Contacts 0 April 17th 07 10:31 AM
EntryID Ela Outlook and VBA 2 April 13th 07 12:10 AM
EntryID is nothing donald Add-ins for Outlook 2 March 20th 06 05:08 PM
EntryID Arne Baldauf Outlook and VBA 3 February 4th 06 05:41 PM


All times are GMT +1. The time now is 10:35 AM.


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.