excel - Import Emails from specific folder in Outlook -
i'm using following code in excel access folders in unmanned outlook mailbox other own.
however there way can set folder in code rather using folder picker.
sub launch_pad() dim olapp outlook.application dim olns outlook.namespace dim olfolder outlook.mapifolder set olapp = outlook.application set olns = olapp.getnamespace("mapi") set olfolder = olns.pickfolder n = 2 cells.clearcontents call processfolder(olfolder) set olns = nothing set olfolder = nothing set olapp = nothing set olns = nothing end sub sub processfolder(olfdstart outlook.mapifolder) dim olfolder outlook.mapifolder dim olobject object dim olmail outlook.mailitem n = 1 each olobject in olfdstart.items if typename(olobject) = "mailitem" n = n + 1 set olmail = olobject cells(n, 1) = olmail.subject cells(n, 2) = olmail.receivedtime cells(n, 3) = olmail.body end if next set olmail = nothing set olfolder = nothing set olobject = nothing end sub
thanks erdem
sub sharemail() dim olnamespace outlook.namespace dim olapp outlook.application dim olns outlook.namespace dim olfolder outlook.mapifolder dim olrecip outlook.recipient set olapp = outlook.application set olns = olapp.getnamespace("mapi") set olrecip = olns.createrecipient("mail@mail.com") set olfolder = olns.getshareddefaultfolder(olrecip, olfolderinbox).folders("myfolder") call processfolder(olfolder) set olapp = nothing set olns = nothing set olrecip = nothing set olfolder = nothing end sub
Comments
Post a Comment