473,725 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET, App - How can i close an Outlook Item?

11 New Member
Hey,
i have written this code to read all Outlook Appointments from another user and fill them into my DGV.

Expand|Select|Wrap|Line Numbers
  1. Public Sub ReadOtherUserAppointment(ByVal UserName As String)
  2.         Dim objolApp As New Outlook.Application
  3.         Dim objNS As Outlook.NameSpace
  4.         Dim objRecip As Outlook.Recipient
  5.         Dim objFolder As Outlook.MAPIFolder
  6.         objNS = objolApp.GetNamespace("MAPI")
  7.         objRecip = objNS.CreateRecipient(UserName)
  8.         objRecip.Resolve()
  9.         Dim i As Integer = 0
  10.  
  11.             If objRecip.Resolved Then
  12.                 objFolder = objNS.GetSharedDefaultFolder(objRecip, Outlook.OlDefaultFolders.olFolderCalendar)
  13.  
  14.                 For x As Integer = 1 To objFolder.Items.Count
  15.                         If objFolder.Items.Item(x).categories = "Urlaub" Then
  16.                         dgv.Rows.Add()
  17.                         dgv.Item("clmstart", i).Value = objFolder.Items.Item(x).start
  18.                         dgv.Item("clmend", i).Value = objFolder.Items.Item(x).end
  19.                         dgv.Item("clmsubject", i).Value = objFolder.Items.Item(x).subject
  20.                         dgv.Item("clmcategory", i).Value = objFolder.Items.Item(x).categories
  21.                         i = i + 1
  22.                     End If
  23. objFolder.Items.Item(x).Close(Outlook.OlInspectorClose.olDiscard)                   
  24.  Next
  25.  
  26.             End If
  27.  
Now when i read the appointments and fill them into my DataGridView there is an Error after some items:
System.Runtime. InteropServices .COMException (0x80040305): Your server administrator has limited the number of items you can open simultaneously. ..

I tried objFolder.Items .Item(x).Close( Outlook.OlInspe ctorClose.olDis card), but this gievs me the error:
System.Runtime. InteropServices .COMException (0x8002000F) Parameter not optional...

Any ideas?

Greetings
Nov 18 '08 #1
1 4676
chrisli
11 New Member
I found a solution :)

After i went through every Item i do this:

Expand|Select|Wrap|Line Numbers
  1. If objRecip.Resolved Then
  2. objFolder = objNS.GetSharedDefaultFolder(objRecip, Outlook.OlDefaultFolders.olFolderCalendar)
  3.  
  4. For x As Integer = 1 To objFolder.Items.Count
  5.  
  6. 'Same code as above...
  7.  
  8. End If            
  9.  
  10. 'Quit the Session when every item is added.
  11.  
  12. objolApp.Quit()
  13.  
  14. 'Run garbagecollector
  15.  
  16. GC.Collect()
  17. GC.WaitForPendingFinalizers()
  18. GC.Collect()
  19. GC.WaitForPendingFinalizers()
  20. Next
  21. End If
  22.  
Simple, huh? :)

Sorry for my bad english.

Greetings from Germany. :)
Nov 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3807
by: Martin Knauer | last post by:
Hi, I try to build an Outlook Plugin. After having some trouble with the Inspectorevents I'm trying to build a wrapper for the Inspectorclass. However I'm stuck again after letting VS.Net 2003 create the stubs for the Inspector-Interface. When I try to compile the new Wrapperclass it says
9
7376
by: John | last post by:
Hi I am using the following code to search for an email message with id myID; Dim SentFld As Outlook.MAPIFolder Dim Email As Outlook.MailItem Dim I As Integer OutlookApp = New Outlook.Application SentFld =
9
3089
by: George McCullen | last post by:
I have an Outlook 2003 using Exchange Server 2003 Public Contacts Folder containing 20,000 Contacts. I am writing a VB .Net 2003 program that loops through all the contacts in a "for each oCt in oItems" loop. After about 250 contacts, the program gives an InvalidCastException Error on the for each loop. I notice that Outlook's memory keeps increasing (using the task manager) until it reaches around 20,000K. When I run the program a second...
6
14674
by: David Anderson | last post by:
Does anyone know how to drag&drop a message with attachments from Outlook (2002 or 2003) in to a VB.Net windows form. This is really stumping me. I've spent a fair amount of time trying to find a solution on the internet, with limited success. I do have code to drag an attachment directly from Outlook to a form, but not a whole message. I want to have access to an object reprensenting the message so I can bust out the message and...
8
2695
by: Li Pang | last post by:
Hi, I used following codes to pass a message item from CDO to Outlook. They worked fine when I used outlook 2000, but get an error of "Specified cast is not valid." when I used Outlook 2003. Anybody has an ideal? Dim outlookMsg AsMicrosoft.Office.Interop.Outlook.MailItem Dim adoMsg As MAPI.Message outlookMsg = Microsoft.Office.Interop.Outlook.Application.Session.GetItemFromID(cdoMsg.ID)
2
1817
by: Snig | last post by:
Hi I'm into creating a web application in C# (.NET Framework 1.1) which would list and manage the outlook tasks. If I try to do this in a Windows Application, it works fine. But there are many issues in case of Web application. Code: Outlook.Application app = new Outlook.Application();
26
4503
by: Tom Becker | last post by:
Is there a way, from Access, to programmatically click the Send and Receive button in Outlook?
2
2792
by: =?Utf-8?B?QWxleGFuZGVyIEtvbW1lcg==?= | last post by:
Hi, I´m developing a feature in a application with the following specification: In the first step, the application should be able to store messages out of outlook, which are dropped on a tree view. This message should be stored as ..msg file. In future, this should be able for alle objects of outlook. If a drop a message out of outlook, I can get the file name of the message
2
4419
by: pkn6 | last post by:
Hi All, I am using VB.net to send my mails through outlook. Where i am giving the resource path for the pictures inserted in to it. But Email shows the inline pictures as attachments. what could be the reason? The important thing is that this is not happening all the time. if we send 5 to 10 times we get the expected result for 2 or 3 times. i explored some of the forums , got answers like 'changing the settings, security settings of the...
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.