Outlook VBA loading a saved file from HD - vba

I've found quite a bit on how to automate saving emails and attachments from Outlook to drive locations, but I'm lost on how to access and manipulate those objects that are now saved. So, as an example, I have a folder on my desktop ('C:\Desktop\emails\') with about 1000 emails, and I need to pull the attachments from each of them. The process of extracting attachments in an iterated method is well documented, I'm just stuck on how to actually specify that folder and use it.

Are the MSG files? Use Application.Session.OpenSharedItem to open each MSG file and get back the MailItem object.

Related

Mail Merge with attachments using Power Automate: Creating Manual Flow

I have been to create a manual flow using Power Automate to complete the following task:
Send an email to a specific recipient with a corresponding pdf attachment.
I have to repeat this task over 150 times since I have a list of recipients.
After watching a few tutorials and experimenting with Power Automate, I was able to create a manual flow to send an email to everyone from my list (Excel File) but I am struggling to figure out how to attach a unique PDF file with each email going out to these recipients.
For my input items, I have:
An excel file with names, email addresses, and the pdf files names
(not the actual attachment, just the name of each file). The file is stored in
OneDrive.
A folder containing all of the PDF files with unique names
(matching the names in the excel file). This folder is stored in
OneDrive.
Basically, what I am attempting to do with the flow is to:
Grab the name of the recipient
Email address
Name of the pdf file
Attach a copy of the pdf file
Send the email with the attachment.
The flow will loop across all the rows in my excel table and complete the actions above until the list is exhausted.
I am sure this can be done in some way in excel but I figured Power Automate can be much more efficient, or maybe any other alternatives that you can suggest.
Thank you in advance for taking the time to read this and sharing some insights.

Saving outlook email attachment to disk to enable reading of file content by strings.exe or exiftool.exe safe?

I am using strings.exe https://learn.microsoft.com/en-us/sysinternals/downloads/strings and
exiftool.exe
to try and establish whether the outlook attachments are the file type that they are listed and just haven't changed their extension
Problem is that both of these tool expect a filepath which would force me to use .SaveAsFile(string path) on the mail item attachment object and save to disk to scan them before I delete them
Is this a security risk?
As far as I know I am not executing the file simply reading its metadata and therefore any malicious files should not be executed right?
I am using this wrapper to read the file from c# https://github.com/AerisG222/NExifTool
I have bitdefender installed on the machine and I know I have tried to save a test virus file and it immediately picked it up and deleted it
I have had a look at redemption and it has an option to return AsStream which would allow to use in memory but to scan with exiftools.exe and strings.exe they are both expecting a filepath
hoping to get answer before so-police comes
It will not be a security risk. The file is never executed.
More than that, OOM blocks certain attachment types (such as exe) - they are not even accessible in the MailItem.Attachments collection (unless you are using Redemption of course).

Is it possible to open an Outlook attachment without saving it?

I'm working on an Excel workbook that scans an Outlook folder, pulls the email data and saves the attachment. A later bit of code then reads the data in each attachment and prints it to a master sheet.
I really want to remove the need to save an attachment and just temporarily open it, take what I need from it and then close it.
I've done a fair bit of research and can't find anything that doesn't involve saving it. It's also worth calling out Outlook VBA is out of the question due to security restrictions so it needs to be done from Excel.
Is it possible to do what I want, and do you have any examples/references I can check out?
Thanks in advance
No. To display/open/read the data you need to save it. Even when you preview it inside Outlook, the file is saved at temp location.
You can always save the file (preferably in User's Temp folder) and after processing the file you can delete it from VBA.
To Delete the a file from VBA , use Kill Command. Make sure the file is closed and then
Kill FullFileName
Example: Kill "C:\Temp\abc.xlsx"

Saving email attachments with Outlook / Exchange when offline

I can save attachments from Outlook automatically using VBA and inbox rules. The problem with this is that I need to be logged in.
Is there any way to save attachments while my machine is turned off?
Sure, if you have a cached profile, all the data is stored in an OST file, and your machine can be offline, but your code can still access the cached messages and attachments.

Outlook Quick Search Folder Structure by Name

Is there any easy way to quickly search for the name of a folder in Outlook's inbox folder structure?
I am talking about this:
I have to categorize emails into this folder structure as they arrive but 99% of the time is looking for the right folder...
We are running our own Exchange and I am using Outlook over rdp
http://i.stack.imgur.com/wZDKS.png
The Outlook object model doesn't provide any property of method for that.
You need to develop a VBA macro or add-in to ge the job done. For example, you can iterate over the folders structure to find the required one. The Folders property of the Folder class returns the Folders collection that represents all the folders contained in the specified Folder. So, you may walk down to the tree recursively.