Need to create shortcut in recent items location
Hello VB Gurus,
I have an Outlook 2010 VBA code that copies the currently highlighted email in inbox to a local drive ( D: ) on my laptop.
I execute this macro via a button on my quick access toolbar on outlook.
I need some sort of VBA code that also creates a shortcut to this email in the recent items location.
Basically, here are the steps i need to achieve.
1 & 2 are achieved, I need macro for the 3rd point below.
1. Highlight an email in my outlook inbox
2. Copy it to a specific location in my D drive.
3. Create a shortcut to this item in recent items folder, so that if i need to upload this email somehwere I can locate it easily from recent items ( C:\Users\tkumar1\AppData\Roaming\Microsoft\Windows\Recent )
Thanks for your assistance.
Regards
Tushar
Re: Need to create shortcut in recent items location
Code:
Set wshshell = CreateObject("Wscript.Shell")
' select shortcut name and folder
Set oshelllink = wshshell.CreateShortcut(wshshell.specialfolders("recent") & "\aaa.lnk") ' change name of link to suit
'Set the Target Path for the shortcut
oshelllink.TargetPath = "c:\somepath\file.msg" ' change name of file to open as required
'Set the additional parameters for the shortcut
' oshelllink.Arguments = "c:\windows\desktop\aaa.txt" ' probably not required in this instance
'Save the shortcut
oshelllink.Save
'Clean up the WshShortcut Object
Set oshelllink = Nothing
Set wshshell = Nothing
note: while is is very simple to add the shortcut to the recent documents folder, this will not push the shortcut to the list that is displayed when you click on recent documents, to do that you will need to edit the recent docments MRU list in the registry, do you want to get that carried away? it may be better to just open the saved item in the default application and allow windows to update the recent documents list for you