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,402
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

Human reproduction process - one spermatozoon, out of 100's of millions, enters the egg and is secured, the fertilized egg becomes a clot and eventually implants itself to the wall of the uterus, referred to as implantation.
Moreover We placed him as a drop (nutfah) in a safe lodging. Then We created the drop (nutfah) into a clinging clot (alaqah).
Qur’an – Surah al-Mu’minun (The Believers) 23:13-14
See also Qur'an 21:30, 21:104 regarding creation and end of the universe (and how a new universe will be created).
Go to the top of the page
 
ADezii
post Dec 5 2018, 09:50 AM
Post#2



Posts: 2,146
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,402
Joined: 18-July 00
From: Faisalabad, Pakistan


Same error.

--------------------
Aziz

Human reproduction process - one spermatozoon, out of 100's of millions, enters the egg and is secured, the fertilized egg becomes a clot and eventually implants itself to the wall of the uterus, referred to as implantation.
Moreover We placed him as a drop (nutfah) in a safe lodging. Then We created the drop (nutfah) into a clinging clot (alaqah).
Qur’an – Surah al-Mu’minun (The Believers) 23:13-14
See also Qur'an 21:30, 21:104 regarding creation and end of the universe (and how a new universe will be created).
Go to the top of the page
 
JonSmith
post Dec 6 2018, 10:08 AM
Post#4



Posts: 3,980
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    12th December 2018 - 12:05 AM