Hello guys,
I have hit a dead end in trying to solve this problem. The thing is, I can't run the the program here because it has to run on a server which is in another place. All I receive here is a logfile with exceptions that happens when they test the program on the server.
I'm using VS2005, VB.NET, XP Pro, CDO 1.21 dll
Anyway, this function Logs on and traverses through "Public Folders" until it finds a folder I'm looking for.
I hope someone could help me cause I need to resolve this fast.
Here is the source code: -
Public Sub Logon(ByVal profile As String, ByVal RootFolder As String)
-
-
m_Session = New MAPI.Session
-
m_Session.Logon(profile, , False, , , , )
-
-
' Go the fax store
-
Dim Folders As String() = RootFolder.Split("/".ToCharArray())
-
-
Dim i As Integer
-
Dim objInfoStores As Object
-
Dim objPublicFolderRoot As Object
-
Dim objParent As Object
-
Dim Parent As MAPI.Folder
-
-
objInfoStores = m_Session.InfoStores
-
m_InfoStores = DirectCast(objInfoStores, MAPI.InfoStores)
-
-
For i = 1 To CInt(m_InfoStores.Count)
-
Dim InfoStoreName As String
-
objPublicFolderRoot = m_InfoStores.Item(i)
-
InfoStoreName = m_InfoStores.Item(i).ToString
-
If InfoStoreName = Folders(0) Then
-
m_PublicFolderRoot = DirectCast(objPublicFolderRoot, MAPI.InfoStore)
-
Exit For
-
End If
-
Next
-
-
objParent = m_PublicFolderRoot.RootFolder
-
Parent = DirectCast(objParent, MAPI.Folder)
-
-
For i = 1 To Folders.Length - 1
-
Parent = GetFolderByName(Folders(i), Parent)
-
Next
-
m_FaxRoot = Parent
-
-
End Sub
-
and this is the code for the GetFolderByName Function -
Friend Function GetFolderByName(ByVal folderName As String, Optional ByVal parent As MAPI.Folder = Nothing) As MAPI.Folder
-
Dim CdoSession As MAPI.Session = m_Session
-
Dim CdoInfoStores As MAPI.InfoStores
-
Dim CdoInfoStore As MAPI.InfoStore
-
Dim CdoFolderRoot As MAPI.Folder
-
Dim CdoFolders As MAPI.Folders
-
Dim CdoFolder As MAPI.Folder
-
Dim bFound As Boolean
-
-
Dim i As Integer = 1
-
Dim objInfoStores As Object
-
Dim objInfoStore As Object
-
Dim objFolderRoot As Object
-
Dim objFolders As Object
-
Dim objParentFolders As Object
-
Dim objFolder As Object
-
-
If parent Is Nothing Then
-
objInfoStores = CdoSession.InfoStores
-
CdoInfoStores = DirectCast(objInfoStores, MAPI.InfoStores)
-
objInfoStore = CdoInfoStores.Item("Public Folders")
-
CdoInfoStore = DirectCast(objInfoStore, MAPI.InfoStore)
-
-
For i = 1 To CInt(CdoInfoStores.Count)
-
Dim InfoStoreName As String
-
objInfoStore = CdoInfoStores.Item(i)
-
InfoStoreName = CdoInfoStores.Item(i).ToString
-
If InfoStoreName = "Public Folders" Then
-
CdoInfoStore = DirectCast(objInfoStore, MAPI.InfoStore)
-
Exit For
-
End If
-
Next
-
-
objFolderRoot = CdoInfoStore.RootFolder
-
CdoFolderRoot = DirectCast(objFolderRoot, MAPI.Folder)
-
objFolders = CdoFolderRoot.Folders
-
-
CdoFolders = DirectCast(objFolders, MAPI.Folders)
-
Else
-
' Get the Folders collection from the parent folder.
-
objParentFolders = parent.Folders
-
CdoFolders = DirectCast(objParentFolders, MAPI.Folders)
-
End If
-
-
' Loop through the folders in the collection until the
-
' desired folder is found.
-
bFound = False
-
objFolder = CdoFolders.GetFirst
-
CdoFolder = DirectCast(objFolder, MAPI.Folder)
-
Do While (Not bFound) And Not (CdoFolder Is Nothing)
-
If CdoFolder.Name.ToString = folderName Then
-
bFound = True
-
Else
-
objFolder = CdoFolders.GetNext
-
CdoFolder = DirectCast(objFolder, MAPI.Folder)
-
End If
-
-
Loop
-
-
GetFolderByName = CdoFolder
-
-
' Release our local objects.
-
CdoFolder = Nothing
-
CdoFolders = Nothing
-
CdoFolderRoot = Nothing
-
CdoInfoStore = Nothing
-
CdoInfoStores = Nothing
-
End Function ' GetFolderByName
-
Please help,
JAN
3 1625
Hi Jan,
As I see the topicname, the first thing I think is: "He forgot to use 'New'". This goes for new objects instances. Try using
Now, as I don't know exactly what exceptions you get it's hard to tell where you should and shouldn't use them, but at least this is a start. You can try posting the list of exceptions...
Hi! Thanks for the reply
This is the only exception i got from the testers
Object reference not set to an instance of an object.
at CDOMessaging.ExchangeConnector.Logon(String profile, String RootFolder)
at InFaxAlert.InFaxAlert.OnWakeup2(Object sender, ElapsedEventArgs e)
I'll try placing "New" in my Object declarations
Like this right? -
Dim objInfoStores As New Object
-
Thanks,
JAN
Hi! Thanks for the reply
This is the only exception i got from the testers
Object reference not set to an instance of an object.
at CDOMessaging.ExchangeConnector.Logon(String profile, String RootFolder)
at InFaxAlert.InFaxAlert.OnWakeup2(Object sender, ElapsedEventArgs e)
I'll try placing "New" in my Object declarations
Like this right? -
Dim objInfoStores As New Object
-
Thanks,
JAN
It's easier to test it instead of asking me if it looks right ;-) It does look right, but I'm not sure whether or not it will work...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bob Cannistraci |
last post by:
A three-tier user authentication system was running without a problem for almost a year and now is suddenly dysfunctional. We don't know of any changes to any of the servers. It's quite maddening....
|
by: Dr Duck |
last post by:
GDay all,
Something seems odd to me....
I wrote a simple C# function
public void bind(ref object a, ref object b, bool atob)
{
if(atob)
b = a;
else
|
by: Chris Magoun |
last post by:
I suddenly received an unexpected error in my project. I have been working
on this project for some time without this issue. Nothing has changed in the
form that caused the exception. A little...
|
by: Microsoft |
last post by:
When I try this in my code I alwas get an errormessage: "Object reference
not set to an instance of an object"
Dim g As System.Drawing.Graphics
g.DrawString("Test", New Font("Arial", 12,...
|
by: Gummy |
last post by:
Hello,
I've been banging my head against the wall for a few days on this.
When I run a page, either in "View in Browser" or I actually build the
solution, I occasionally and very randomly get...
|
by: louie.hutzel |
last post by:
This JUST started happening, I don't remember changing any code:
When I click the submit button on my form, stuff is supposed to happen
(which it does correctly) and a result message is posted back...
|
by: Chris |
last post by:
Hi,
I tried to create a class which must change the propety 'visible' of a
<linktag in the masterpage into 'false' when the user is logged. But i get
the error: "Object reference not set to an...
|
by: Tamer Ibrahim |
last post by:
Hi,
Sometimes, I got the following error message when I use ajax calendar
control on some aspx pages :
Object reference not set to an instance of an object.
Description: An unhandled exception...
|
by: My Pet Programmer |
last post by:
Ok guys, I'm really looking for someone to tell me how bad a hack this
is, and if I'm close to where I should be with it.
The basic situation is that I have a class which creates a basic...
|
by: snester |
last post by:
Hi,
I am using visual studio 2005 and recently created a new web service project. I seem to have edited the global config file (inadvertently) somewhere along the line.
All new projects I...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
| |