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
> Change The Outlook Folder For An E-mail, Access 2007    
 
   
pere_de_chipstic...
post Oct 21 2017, 04:05 PM
Post#1


UtterAccess Editor
Posts: 10,112
Joined: 8-November 07
From: South coast, England


Hi to my Utter Friends

How do I move an e-mail from its current folder to a subfolder of its current folder?

I have the following code structure, but don't know how to move the e-mail.

CODE
OLSubFldr = Nz(DLookup("MusReplyEmailFldr", "tblAdmin", "AdminID=1"), "")
Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
Set InboxItems = Inbox.Folders.Item(OLSubFldr).Items
For Each Mailobject In InboxItems
If Mailobject.UnRead Then
'Lots of other code!
Mailobject.UnRead = False
' Move MailObject from Outlook.CurrentFolder to Outlook.CurrentFolder/SubFolderName ' << I want to implement this
End If
Next Mailobject


Thanks in advance.

--------------------
Warm regards
Bernie
Go to the top of the page
 
pere_de_chipstic...
post Oct 21 2017, 06:08 PM
Post#2


UtterAccess Editor
Posts: 10,112
Joined: 8-November 07
From: South coast, England


I've made a little progress on this:

CODE
OLSubFldr = Nz(DLookup("MusReplyEmailFldr", "tblAdmin", "AdminID=1"), "")
Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
Set InboxItems = Inbox.Folders.Item(OLSubFldr).Items
Set strDestFldr = Inbox.Folders(OLSubFldr).Folders("SubFolder Name") '<<This errors - "An object could not be found"
For Each Mailobject In InboxItems
If Mailobject.UnRead Then
'Lots of other code!
Mailobject.UnRead = False
Mailobject.Move strDestFldr ' Move MailObject
End If
Next Mailobject


Seems to be the formatting of the Set strDestFldr command (in red above)?

--------------------
Warm regards
Bernie
Go to the top of the page
 
pere_de_chipstic...
post Oct 21 2017, 06:22 PM
Post#3


UtterAccess Editor
Posts: 10,112
Joined: 8-November 07
From: South coast, England


Sorted!

Set strDestFldr = Inbox.Folders.Item(OLSubFldr).Folders("SubFolder Name")

Thanks for looking in thumbup.gif

--------------------
Warm regards
Bernie
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    15th December 2017 - 10:13 PM