outlook - VBA - For Each loop ends after first item -




i'm trying write simple macro add received date subject line of email.
i've compiled code below , works single e-mail. however, appears for each loop ends after first email, , i'm @ total loss on how solve this. i've tried changing the pickfolder line activeexplorer.selection line - same problem.

    sub selectedmailitemssubjectwithdate()         dim objmainfolder outlook.folder         dim mobj outlook.mailitem           set objmainfolder = outlook.application.session.pickfolder              each mobj in objmainfolder.items                 'adds date subject                 mobj.subject = format(mobj.receivedtime, "yyyymmdd") & " - " & mobj.subject             next mobj     end sub 

is there can me this? obliged!


the reason i'm trying add date need archive thousands of e-mail in .msg format, in online storage doesn't show except subject line of file.

wait sec, how know 1 item processed? stepping through code , see loop exits prematurely? or 1 item modified? in latter case need save item:

mobj.subject = format(mobj.receivedtime, "yyyymmdd") & " - " & mobj.subject mobj.save 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -