Excel VBA: Move Outlook email in public folder without using GetNamespace("MAPI") -
i'm trying following: have list of email in subfolder of inbox (named "a_classer") need run code take emails , place them in folder. destination folder vary based upon subject of message. need in excel because destination file vary based upon information in excel workbook.
so problem i'm using windows 32 bit system. i've read seems doesn't support getnamespace("mapi") method. because when run "error 438" @ getnamespace("mapi") line
if destination file reside in inbox, need move emails public folder.
so here code far. if me pass error 438 helpfull.
sub move_to_public_folder() dim msg outlook.mailitem dim olfolder outlook.folder 'public folder want email moved dim sourcefolder outlook.folder 'current folder of emails moved dim olapp object dim mynamespace outlook.namespace dim myrecipient outlook.recipient set olapp = createobject("outlook.application") 'ouverture du outlook set mynamespace = application.getnamespace("mapi") 'where 438 error set myrecipient = mynamespace.createrecipient("guillaume.hebert") set olfolder = session.getshareddefaultfolder(myrecipient, olpublicfoldersallpublicfolders) set olfolder = olfolder.folders("\q12") set sourcefolder = session.getdefaultfolder(sourcefolderinbox) set sourcefolder = sourcefolder.folders("a_classer") if sourcefolder nothing exit sub = sourcefolder.items.count nbre_op = 'détermine combien de courriel dans le répertoire = 1 while <= nbre_op set msg = olfolder.items(1) msg.move olfolder = + 1 wend set olapp = nothing
end sub
thank in advance!
try
... set mynamespace = olapp.getnamespace("mapi") ...
as olapp
of type application object (outlook) whereas application
of type application object (excel) when refer within excel macro , such not have usable getnamespace
method
Comments
Post a Comment