Saving email attachments with Outlook / Exchange when offline - vba

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.

Related

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).

Mozilla Thunderbird: recovering emails from global-messages-db.sqlite

How can I recover lost emails from Thunderbird's global-messages-db.sqlite?
My PC kernel panicked in the middle of migrating some emails from Imap to local storage. As a result, that migration did not complete writing to disk.
Due to the failed migration, many emails exist in global-messages-db.sqlite but do not exist in corresponding mbox files (eg not in Mail/username#hostname.tld). I verified that the emails exist in global-messages-db.sqlite via sqlitebrowser. In fact, I've successfully manually extracted the content of some critical messages.
Upon startup, Thunderbird is culling from global-messages-db.sqlite emails it does not find in mbox files. If I replace the active global-messages-db.sqlite with a version containing my lost emails, Thunderbird ignores and eventually removes those lost emails.
This would be a trivial dilemma if I still had access to the Imap account. Unfortunately, I do not.
Scripting a converter is trivial
I would quickly code a gloda->mbox converter, that's probably your fastest path to success. You've already discovered the structure of the gloda database. Now, it's just a matter of writing a little JavaScript in node.js that opens an sqlite database, iterates over the folders, then the messages in each folder, and writes an mbox file for each folder. The mbox file format is trivial (just pay attention for "From"). Once you have that, you can open these mbox files in Thunderbird by just overwriting an existing empty Local Folder.
P.S. Just as a reminder: Make backups. Esp. before such migration operations, but also regularly.

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"

Outlook VBA loading a saved file from HD

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.

Deleting pfd files after sending as mail attachments

I know its kind of repeated question but m getting an error message as 'File cannot be accessed as it is being used by other process'. When I run my exe through a batch process.
On running the exe directly in the remote server, I donot get any such error but batch process causes this to happen. The batch process goes into an infinite loop and never ends. even though the exe functions properly. Reports are created and I recieve them as mail attachment.
M using smtpclient to send mails. I ahve also used MailMessage.Attachments.Dispose() and MailMessage.Dispose() to kill the attachment objects.
I got the correct way.
I was disposing the mailmessage object first and then the attachment object.
Just had to reverse the order and it worked perfectly!
Thanks!