Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Error coming up when using "GetItemFromID"

Posted on 2012-03-31
10
Medium Priority
?
755 Views
Last Modified: 2012-04-06
Hi Team,

I am trying to run the given below code and I am not able to proceed further as it is giving me some error.  It had run for a couple of times, but stoped working all of a sudden.

Given below is the code.

Private Sub cmdViewEmail_Click()
    Dim olFolder As Outlook.MAPIFolder
    Dim olConversationIndex As String
   
    olConversationIndex = [Form_qryEmails&Comments subform].Conservation_Index
    Set olFolder = GetOlFolder("\\Mailbox - Operations Collections\Inbox")
   
    Set Test = olFolder.Session.GetItemFromID("0101CD0EB640F8EC9BCA09902E4383A0DE3146196E1A9683932700800178B580")
    Test.Display
   
End Sub


Given below is the error I get when I try to run the above code.

Error Screen shot.
I also did some further testing and it seems to work for certain emails and does work for certain emails.  Please note the folder has only emails, no calander or task etc..

Thanks,
Sandesh.
0
Comment
Question by:Sandesh555
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 37792548
Are you sure that an Item with that ID exists?
0
 
LVL 2

Expert Comment

by:adamnl
ID: 37793041
If they exist, are they in \Mailbox - Operations Collections\Inbox ?
0
 
LVL 31

Accepted Solution

by:
Helen Feddema earned 1500 total points
ID: 37793374
Also, I don't see a declaration for Test.  Is it supposed to be a MailItem?

And in this line:  olConversationIndex = [Form_qryEmails&Comments subform].Conservation_Index

you have "Conservation_Index" and "olConversationIndex".  Shouldn't they both be Conversation?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Sandesh555
ID: 37794550
Hi Team,

Each and every mail item that I have captured in my database exits and In case of the given coding, sorry for the confusion.  I had included only a part of the code and did not remove all the not related lines.  Here is the code again.

Private Sub cmdViewEmail_Click()
    Dim olFolder As Outlook.MAPIFolder
   
    Set olFolder = GetOlFolder("\\Mailbox - Operations Collections\Inbox")
   
    Set Test = olFolder.Session.GetItemFromID("0101CD0EB640F8EC9BCA09902E4383A0DE3146196E1A9683932700800178B580")
    Test.Display
   
End Sub

GetOlFolder() here is a small function which converts the given Outlook folder path into a proper MAPI Folder path.

I did try to declare Test as a MailItem, but was getting same error.  Please note I problem here is that this code is working for a few emails and does not work for a few emails.

Thanks,
Sandesh.
0
 
LVL 2

Expert Comment

by:adamnl
ID: 37797568
What is the difference between the mails for which it does work and the mails for which it does not?
0
 

Author Comment

by:Sandesh555
ID: 37799713
Not much all of them are emails sent and recived by the customer.
0
 

Author Comment

by:Sandesh555
ID: 37799853
HI Team,

I did some testing and found out that all the emails that have been sent from my domain is coming up in the dispaly, but all the emails that have been sent by external team is not wokring.

I am also giving you  the question were I got this solution.

http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_27655636.html

Thanks,
Sandesh.
0
 

Author Comment

by:Sandesh555
ID: 37802882
Hi Team,

After doing some additinal testing I found that the first time I use this code.  It works for all emails.  But later it starts to work only on emails sent from my domain.

I think we jsut need to clear some memory somewere.  All I need to know is what is it that I need to clear.

Thanks,
Sandesh.
0
 

Author Comment

by:Sandesh555
ID: 37803007
Hi Team,

I have found the solution locally, though another developer.

thanks for looking into the same.

Thanks,
Sandesh.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question