473,503 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

no compile errors but code doesn't work properly

1 New Member
wonder if anyone can help... I have access db with a whole lot of vb code... If i use access 2000 it works perfectly but when using 2003 it doesn't work properly. The db copies outlook mailboxes... I'm not quite sure why it wont work properly, i can copy my own mailbox but trying to copy some elses wont work, if i export the mailboxes directly through outlook then i can copy them... this isn't an outlook related issue... here is the code which doesn't seem to work:
Expand|Select|Wrap|Line Numbers
  1. Private Sub CopyMailItems(ns As Outlook.NameSpace, strUserFullName As String, strRecip As String)
  2.     On Error GoTo CopyErrHandler
  3.  
  4.     Dim folder1 As MAPIFolder, oFolder As MAPIFolder
  5.     Dim strMailboxName As String, strStatus As String
  6.     Dim intConnect As Integer, intOther As Integer
  7.     Dim strDupTest As String, ErrString, strSearch As String
  8.     Dim Complete As Boolean
  9.  
  10.     Set dbs = CurrentDb
  11.     Set rst = dbs.OpenRecordset("Status")
  12.     MsgBox "copymailitems1", vbOKOnly, "test"
  13.     intConnect = ConnectToBox()
  14.     If intConnect = 6 Then
  15.     MsgBox "copymailitems2", vbOKOnly, "test"
  16.         strMailboxName = "Mailbox - " & strUserFullName
  17.         Set UserMailbox = ns.Folders(strMailboxName)
  18.         'If user has not connected to mailbox, rest of code will not run. Error Handler will "kick in"
  19.         strStatus = StatusTest()
  20.         MsgBox "copymailitems3", vbOKOnly, "test"
  21.         If strStatus <> "Copy Started" Then            
  22.         MsgBox "copymailitems4", vbOKOnly, "test"
  23.             strStatus = "Copy Started"
  24.             Call UpdateStatus(strStatus)
  25.         End If                                        
  26.         Screen.MousePointer = 11
  27.  
  28.     'Copy folders and its subfolders to empty pst
  29.         strPstFolderName = CreateEmptyPst(ns, strRecip, strUserFullName)
  30.         MsgBox "copymailitems5", vbOKOnly, "test"
  31.         Set PersonalFolder = ns.Folders(strPstFolderName)
  32.         For Each folder1 In UserMailbox.Folders  'ns.Folders(strMailboxName).Folders
  33.         MsgBox "copymailitems6", vbOKOnly, "test"
  34.             Set CopiedFolder = folder1.CopyTo(PersonalFolder) '****
  35.         MsgBox "copymailitems7", vbOKOnly, "test"
  36.         Next
  37.         MsgBox "copymailitems8", vbOKOnly, "test"
  38.         Set CopiedFolder = Nothing
  39.     'copy messages from top of Information Store to pst
  40.         For Each msg In ns.Folders(strMailboxName).Items
  41.             MsgBox "copymailitems9", vbOKOnly, "test"
  42.             Set CopiedItem = msg.Copy
  43.             CopiedItem.Move PersonalFolder
  44.         Next
  45.         Set CopiedItem = Nothing
  46.         Set oFolder = ns.Folders.Item(strPstFolderName)
  47.  
  48.         Screen.MousePointer = 0
  49.         Complete = VerifyContents(ns, strMailboxName)
  50.         If Complete = True Then
  51.             MsgBox "All items have been copied.", vbOKOnly + vbInformation, "Mailbox Copy"
  52.             strStatus = "Copy Complete"
  53.            ' Set objFolder = objName.Folders.Item("Personal Folders")
  54.            ns.RemoveStore PersonalFolder
  55.         Else
  56.             MsgBox "Please copy data to folders where differences have been noted. " & _
  57.                "Please revisit page once copying has been completed", vbOKOnly + vbInformation, _
  58.                 "Mailbox Copy"
  59.             strStatus = "Copy Partial"
  60.             DoCmd.OpenForm "frmCopyComplete"
  61.         End If
  62.         Call UpdateStatus(strStatus)
  63.     End If
  64.  
  65. CopyErrHandler:
  66.     Select Case Err.Number
  67.         Case -2147221233 'Not connected to user's mailbox in Outlook
  68.             intConnect = ConnectToBox()
  69.             If intConnect = 6 Then
  70.                 Resume
  71.             End If
  72.     Case Else
  73.         strSearch = "Can't copy folder." 'don't have permission to copy folder
  74.         ErrString = InStr(1, Err.Description, strSearch)
  75.         If ErrString = 1 Then
  76.             Resume Next
  77.         End If
  78.     End Select
  79.  
  80.     Screen.MousePointer = 0
  81.  
  82. End Sub
  83.  
  84. i have added the msgboxs which says copymailitems, just to try see where it stops working... it would seem like it is after this line:
  85.  
  86. MsgBox "copymailitems6", vbOKOnly, "test"
  87.             Set CopiedFolder = folder1.CopyTo(PersonalFolder)
  88.  
Any ideas or anything would be greatly appreciated...

Thanx
Aug 5 '09 #1
0 1525

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

Similar topics

4
2332
by: Thomi Richards | last post by:
Hi, I'm trying to create a simple stack class using C++ and templates. Everything works well and good if I amke the class totally inline. However, as soon as I try to seperate the class into a...
12
2481
by: Russ | last post by:
Hello. My new dev machine is running XP Pro. In the past all equipment has only used Windows 2000. I have had a lot of problems getting my projects up and running on the new machine. The current...
5
3301
by: Carmine Cairo | last post by:
Hi, I'm working on a project and today I've note a little problem during the compile fase. Here a little piece of code: // 1st version welldone = 0; size = p->getSize(); backbone = new...
10
19690
by: Chris LaJoie | last post by:
Our company has been developing a program in C# for some time now, and we haven't had any problems with it, but just last night something cropped up that has me, and everyone else, stumped. I...
7
4478
by: Holger (David) Wagner | last post by:
Hi Group, I've searched the Web for precompilers that compile ASPX/ASCX pages just like it can be done with JSPs, but so far, I've only found approaches targetted at increasing the performance....
9
4164
by: collection60 | last post by:
I've been developing some Unix based shell tools. They work fine on Linux and MacOSX. I want to compile them on Win32. But I can't get hash_map to compile. I tried downloading stl (and...
9
2402
by: Boris Yeltsin | last post by:
I use Master Pages, so I make use of URL rebasing through the ~ operator, like this in the <head>: <link runat="server" href="~/Root.master.css" media="screen" rel="stylesheet" type="text/css" />...
14
5487
by: mistral | last post by:
Need compile python code, source is in html and starts with parameters: #!/bin/sh - "exec" "python" "-O" "$0" "$@" I have installed ActivePython for windows.
9
2084
by: Finger.Octopus | last post by:
I dont know whats terribly going wrong with this, well I know there's some memory allocation with this but I tried hard to fix it and when it gets fixed it doesn't shows up the desired value, this...
0
7278
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,...
0
7456
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...
0
5578
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,...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3166
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...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1510
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 ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
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...

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.