UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Moving An Email To An Outlook Folder, Access 2013    
 
   
azizrasul
post Nov 30 2018, 10:47 AM
Post#1



Posts: 1,439
Joined: 18-July 00
From: Faisalabad, Pakistan


I have the following code which is a direct copy of code I have elsewhere, except that the original code had a mailbox that contained no spaces, whereas the code below does.

I get the error on line
CODE
Set olMoveToFolder = olSession.Folders(strMailbox).Folders("Inbox").Folders("FAILED")

CODE
    Dim oApp As Outlook.Application
    Dim olSession As Outlook.Namespace
    Dim olStartFolder As Outlook.MAPIFolder, olMoveToFolder As Outlook.MAPIFolder
    Dim olMail As Outlook.MailItem

    'Move the email to 'FAILED' folder.
    strMailbox = "Ecology Resource Planning"
                        
    Set oApp = New Outlook.Application
    Set olSession = oApp.GetNamespace("MAPI")
    Set olStartFolder = olSession.Folders(strMailbox).Folders("Inbox")
    Set olMoveToFolder = olSession.Folders(strMailbox).Folders("Inbox").Folders("FAILED")

The error is '-2147221233 - The attempted operation failed. An object could not be found.'

--------------------
Aziz
Go to the top of the page
 
ADezii
post Dec 5 2018, 09:50 AM
Post#2



Posts: 2,263
Joined: 4-February 07
From: USA, Florida, Delray Beach


If the FAILED Folder is at the same Level as the Input Box Folder, try:
CODE
Set olMoveToFolder = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders("FAILED")
Go to the top of the page
 
azizrasul
post Dec 6 2018, 09:53 AM
Post#3



Posts: 1,439
Joined: 18-July 00
From: Faisalabad, Pakistan


Same error.

--------------------
Aziz
Go to the top of the page
 
JonSmith
post Dec 6 2018, 10:08 AM
Post#4



Posts: 4,033
Joined: 19-October 10



Enumerate the mailboxes available. Find the proper name.


CODE
debug.print olSession.Folders(1).Name


If you do that you'll see all the names of the folders available in that session. Do that in break mode when you have the error so that olSession is instances and refers to an instance.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    23rd April 2019 - 07:10 PM