|
-
Jun 26th, 2006, 08:53 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Cannot move emails
Hi guys!!!
Need help. Cannot move e-mail to folder. Don't know why.
VB Code:
Dim OrganizerApplication As New Outlook.Application
Dim OrganizerNS As Outlook.NameSpace
Dim OrganizerFolder As Outlook.Folders
Dim DestFolder As MAPIFolder
Dim InboxItem As Outlook.MailItem
Dim InboxCount As Integer
Dim DestFolderCount As Integer
Dim Sender As String
Dim CompareFolder As String
Set OrganizerNS = OrganizerApplication.GetNamespace("MAPI")
Set OrganizerFolder = OrganizerNS.Folders.Item("Mailbox - Ian Eco (DHL PH)").Folders
Set DestFolder = OrganizerNS.Folders.Item("IAN Personal")
InboxCount = 1
Do While Not InboxCount = OrganizerFolder.Item(2).Items.Count
On Error Resume Next
Set InboxItem = OrganizerFolder.Item(2).Items.Item(InboxCount)
If Err = 13 Then
Else
Sender = InboxItem.SenderEmailAddress
DestFolderCount = 1
Do While Not DestFolderCount = DestFolder.Folders.Count + 1
CompareFolder = Replace(DestFolder.Folders.Item(DestFolderCount), " ", ".")
If InStr(1, Sender, UCase(CompareFolder)) > 0 Then
InboxItem.Move (DestFolder)
End If
DestFolderCount = DestFolderCount + 1
Loop
End If
Err = 0
InboxCount = InboxCount + 1
Loop
-
Jun 26th, 2006, 09:42 PM
#2
Re: Cannot move emails
I take it that this is not your mailbox? Do you have the proper permissions when and if the other user shared or delegated his inbox?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 26th, 2006, 10:13 PM
#3
Thread Starter
Hyperactive Member
Re: Cannot move emails
No this is my inbox in Exchange Server.
But I wanted it to transfer to my Personal Folders.
-
Jun 26th, 2006, 10:16 PM
#4
Re: Cannot move emails
"IAN Personal" is your added pst file?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 26th, 2006, 11:32 PM
#5
Thread Starter
Hyperactive Member
-
Jun 26th, 2006, 11:56 PM
#6
Re: Cannot move emails
Then you need to reference it by the StoreID also and not just the folder name possibly. Do you get a correct reference to it with the MAPIFolder object? Can you read items in it?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 27th, 2006, 12:08 AM
#7
Thread Starter
Hyperactive Member
Re: Cannot move emails
Yes I can read everything.
I can also delete and copy the inbox mail message.
I can also move it to the calendar which is very weird.
I just can't move it to the Personal Folder.
How do you use StoreID?
-
Jun 27th, 2006, 12:14 AM
#8
Re: Cannot move emails
No, I mean can you read, add, delete and such on the pst mapifolder object?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 27th, 2006, 12:56 AM
#9
Thread Starter
Hyperactive Member
Re: Cannot move emails
Yes I can read, add, delete programmatically.
-
Jun 27th, 2006, 01:31 AM
#10
Re: Cannot move emails
Take out the "On Error Resume Next" and step through your code. What line is generating an error and what does it say?
I dont know about this line:
Set InboxItem = OrganizerFolder.Item(2).Items.Item(InboxCount)
Shouldnt you beiterating through the items of the OrganizerFolder or is it a subfolder that your looking into?
Also, dont like this loop:
Do While Not InboxCount = OrganizerFolder.Item(2).Items.Count
As you should either have a For x = 1 to OrganizerFolder.Item(2).Items.Count
or a For Each itm In OrganizerFolder.Item(2).Items.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 27th, 2006, 01:54 AM
#11
Thread Starter
Hyperactive Member
Re: Cannot move emails
If I remove the On Error Resume Next I will get a Type Mismatch Error because I have a Meeting Request on my Inbox.
The loop works but I will still change it for better code practice. Thanks for that.
Yes you are right, I am trying to move my mails to their respective sub-folders.
Here is the sample:
Inbox
Mail
Personal Folder
Folder for a
Folder for b
Folder for c
Hope this gives you a clearer picture of what I mean.
-
Jun 28th, 2006, 09:30 PM
#12
Re: [RESOLVED] Cannot move emails
Are these all top level pst files or folders or ? Can you draw teh folder structure or attact a small screen shot?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 28th, 2006, 10:28 PM
#13
Thread Starter
Hyperactive Member
Re: [RESOLVED] Cannot move emails
 Originally Posted by RobDog888
Are these all top level pst files or folders or ? Can you draw teh folder structure or attact a small screen shot?
Oh, thanks for your reply.
I'm sorry if I did not told you that I found the error.
I have forgotten that when you use the parenthesis in an expression it will definitely read as a function and not a sub procedure.
VB Code:
InboxItem.Move(Something)
Will not work. It should be these:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|