I'm trying to assign a VBA script in MS Outlook so that I can get all emails saved in a newly created folder (named by date, files also named by date).
I create a folder and assign name to it:
strNewFolderName = Format(dtDate , "yyyymmdd", vbUseSystemDayOfWeek, _
vbUseSystem)
sName = Item.Subject
ReplaceCharsForFileName sName, "_"
MkDir ("C:\Users\Albertan\My Documents\Messages" & strNewFolderName)
Then I'm trying to save the email in this newly created folder:
sPath = "C:\Users\Albertan\My Documents\Messages"&StrNewFolderName
Debug.Print sPath & sName
Item.SaveAs sPath & sName, olMSG
But it is not saving there. Something wrong with my SPath. I think it is not recognizing the folder name (variable that I use).
Does anybody have any suggestion?
Thank you
I create a folder and assign name to it:
strNewFolderName = Format(dtDate , "yyyymmdd", vbUseSystemDayOfWeek, _
vbUseSystem)
sName = Item.Subject
ReplaceCharsForFileName sName, "_"
MkDir ("C:\Users\Albertan\My Documents\Messages" & strNewFolderName)
Then I'm trying to save the email in this newly created folder:
sPath = "C:\Users\Albertan\My Documents\Messages"&StrNewFolderName
Debug.Print sPath & sName
Item.SaveAs sPath & sName, olMSG
But it is not saving there. Something wrong with my SPath. I think it is not recognizing the folder name (variable that I use).
Does anybody have any suggestion?
Thank you