In our company we follow a process where in a team saves e-mails in a shared folder from where people from another team are supposed to pick and start processing. As a improvement idea I was looking for a macro which upon triggering can loop through all the saved e-mails in that folder and can save or bring them in a outlook sub-folder of the processor's inbox of this team.
I have tried and figured out a code from internet which can copy files from one folder to another (please see below) but could not get to modify it to save the .msg files in the outlook subfolder. This is doable manually so was thinking there should be a macro as well which can do it automatically.
Any help will be highly appreciated. Thank you in advance .
Sub Download_sub()
Application.EnableCancelKey = xlDisabled
'downloads the submission mail item into users download folder
Set fobj = CreateObject("Scripting.FileSystemObject") 'create the file system object
fobj.CopyFolder sht_Databases.Range("B21").Value & "\MailFolder" & _
, sht_Databases.Range("B22").Value
Set fobj = Nothing 'release the variable
End Sub
You can use
Application.CreateItemFromTemplate and pass the folder as the second parameter. Note that the message will be created in the unsent state and no sender properties will be copied.
Namespace.OpenSharedItem to open an MSG file, then copy it to a given folder using MailItem.Move().
Related
Currently users have their own inbox folder and due to corporate policy emails will automatically be deleted after a set period of time.
Some emails however users would like to be able to keep for reference.
In order to accomplish allowing users to keep their importasnt emails; a personal folder file .pst needs to be created. The deletion policy will on affect the exchange profile folder that they currently use. This special personal folder should not be touched by the corporate system.
I need to be able to run a powershell script to automatically create this folder for the user (logged in user on the computer) and assign it in outlook 2019 for use, the user will then copy their specific emails into that personal folder. If I can't do it for the current logged in user - then by a collection of usernames and put in their one drive folder ??
Anyone with knowledge of how to or code to do this, I would appreciate your help - while I can code - I'am not a Powershell Guru so specifics and functions that experts might know exactly - I do not know, so please in your answer provide good guidance.
I am using windows 10 .1909 and the powershell version that ships with it.
The Outlook object model provides the AddStoreEx method which adds a Personal Folders file (.pst) in the specified format to the current profile.
Sub CreateUnicodePST()
Dim myNameSpace As Outlook.NameSpace
Set myNameSpace = Application.GetNamespace("MAPI")
myNameSpace.AddStoreEx "c:\" & myNameSpace.CurrentUser & "\.pst",olStoreUnicode
End Sub
After creating additional storage in the Outlook profile users can move items for keeping them locally. Or you may consider creating a VBA script or COM add-in for doing that programmatically. See Walkthrough: Create your first VSTO Add-in for Outlook for getting started quickly.
I have written a VBScript that helps me organise my desktop every time it gets messy.
It works fine it moves my files and shortcuts based on the extension and the name of the app. However, I have a few app shortcut links that just won't move. in fact the vbs script will not even see them with this basic script
Set FSO = CreateObject("Scripting.FileSystemObject")
dir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
Set folder = FSO.GetFolder(dir)
Set files = folder.Files
For Each file in files
MsgBox file.Name
Next
The files in question are all shortcuts they are iTunes, VLC, Google Chrome and WinRar.
Is there anything I can check to see why vbs won't even see these files?
What You can see on your desktop is hybrid view of two folders:
C:\Users\YourUsername\Desktop
C:\Users\Public\Desktop
Where the Public one is usually a place, where shortcuts are being created during app install, so all users do have them. In your script You are only looking for files in the YourUserName\Desktop, that's why the script does not see those shortcuts.
I need to rename image files sequentially as they are added to a folder. ie. image-0001.jpg and image-0002.jpg are in a folder I add test.jpg and it is renamed image-0003.jpg. I have tried automators rename function but it will start over with image-0001.jpg each time a new file is added instead of continuing the sequence.
Any help is greatly appreciated.
You could make this easy on yourself by using a handy application built into the OS called "Folder Actions". Folder Actions contains one or more special handlers, formally known as folder action event handlers, that run when they are triggered by a change in the target folder. I know I'm confusing but I'll do my best.
What you are trying to accomplish requires an adding folder items to event handler. It requires one direct parameter, which can be anything you wish i.e. target_folder. The handler requires an additional parameter as well; after receiving, which should also be a variable name, i.e. these_items. I have composed a script for you that should do the trick. I have added comments that show you what I'm doing when I do it. Here it is:
on adding folder items to the target_folder after receiving these_items
tell application "Finder"
set all_images to every item of the target_folder as list
repeat with i from 1 to the count of these_items --iterates through all the items you dropped in the folder
set this_image to item i of these_items --the current image
set the name of this_image to "image" & (i + the count of all_images) as string --renames the image based on the number of images already in the folder
end repeat
end tell
end adding folder items to
YAY! The script is done! But are WE done? Not quite. We still need to attach the script to a folder (the script won't run if you try to execute it in script editor).
To do this, first save the script as a Script File in the Folder Action Scripts folder in the Scripts folder in either the local Library folder or the current user's Library folder. Create the folder yourself if it doesn't already exist. Next, launch the Folder Actions Setup application by double-clicking it in the AppleScript folder in the Applications folder. In the window that comes up, click the + button under the table on the left (click the "Enable Folder Actions" checkbox if it isn't already checked) to open a standard file browser sheet, navigate to your desired folder, and click "Open". The Choose a Script to Attach sheet automatically opens, listing all the scripts in all of the Folder Action Script folders. Choose the newly-created script, click "Attach", and BAM you are done!
To see the script in action, drag an image onto the folder. The image is instantly renamed, regardless of if the folder window is open. If you have any questions, or if the script doesn't work, just ask me. :)
well without digging through some code and handin you an answer I'll tell you want you want to do
is create a while loop that checks for the existence of image-000 & i where i is a variable of course and if it exists increment i then when the file doesn't exist rename your file.
I'm looking for a way to put an event trigger on a Windows XP folder which would automatically copy a file from folder1 to folder2 when the file as created in folder1, ideally with System permissions. The purpose is to make a secure repository for files which would be protected. I've looked at WMI, but can't figure out how to get it to trigger on the folder. Any pointers in the right direction would help. Thanks!
If you want to use WMI and need to monitor your folder all the time, you can use WMI permanent event subscription.
You would:
Create a WMI filter ( a query like this, for example: "Select * From __InstanceCreationEvent Within 5 Where TargetInstance Isa 'Cim_DataFile' And TargetInstance.Drive = 'C:' and TargetInstance.Path = '\folder\subfolder\'")
Create a WMI event consumer (a batch or VBScript file to copy the created file to your new location)
Bind the two together
This way you would ensure that the folder is monitored 'at all times' (as long as WMI service is running). You can use VBScript, PowerShell, C# or MOF to set this up. (See the Script Center blog for details)
I'm developing an Outlook addin in C# and have a problem distinguishing mails opened from a folder (Inbox, Sent etc) from mails opened from a standalone .msg file.
I've tried inspecting the Parent property, but it shows Inbox for both kinds.
Any ideas out there?
/Sam
Looking through the properties, it looks to me that the .EntryID property is blank if the MailItem is opened from the file system, and has a value if the file is opened from within a folder. This makes sense based on the help entry for it; one caveat is that you'd also expect this property to be blank if the message is a new message (i.e. hasn't been saved in a folder, but doesn't exist in the file system either).
From the help concerning blank values:
Therefore, the EntryID property is not
set for an Outlook item until it is
saved or sent
You'd want to experiment with it and make sure it definitely behaves correctly before you implemented it :)
Failing all THAT, the next step could be complex; one approach would be to inspect the handles opened by Outlook. Inspecting them (in a non-priveleged context) via Process Explorer shows that there is a handle for each message; the name of the handle matches the message subject, the path is the file's path. One solution to enumerate these is in this answer.
HTH,
Geoff