Programmatically add a .MSG file to an outlook folder - vba

I am attempting to create a PST with a sample of MSGs.
Rather than dragging and dropping into the desired folders, does the Outlook.MAPIFolder in (VBA) provide a way to add a .MSG file from the file system into an Outlook folder (I do not want to recreate the MSG, something akin to drag and drop into a folder).
My simple use case is
I have a file someEmail.msg on my local file system in a folder say
c:/someLocalFileSystemFolder
In Outlook I have a pst folder say somePSTFolder
I want to import someEmail.msg into somePSTFolder such that the
structure is
somPSTFolder
+ someLocalFileSystemFolder
+ + someEmail.msg
I have managed to recreate my local file system folder structure into the pst folder structure using VBA. Is it possible to import msgs programmatically?

Consider using the .Move method, documented here:
http://msdn.microsoft.com/en-us/library/office/ff860683(v=office.15).aspx
Whether the message is re-created, I am not certain. If so, you could always simply delete it from the source if you no longer need it.

Related

How do I embed an exe file in an MS Access Form and Run it at run time?

I'm using MS Access 2003 for Special and old problems with the .mdb project
I want to embed my files like .txt or .exe or .pdf and run them at runtime or write that on disk.
What have I tried :
enter image description here
I don't know what's the code to do what I need I couldn't find my solution on internet.
Private Sub Form_Load()
'Me.OLEUnbound2.Application.Run
Dim obj As Object
Set obj = Me.OLEBound1.Object
'obj.DoVerb (acPrimaryVerb)
End Sub
Update:
I wrote a C# program called BMH.exe, which I open and run through Access, but I want this file to be in my source in any way possible so that the user does not have to place this file next to the program or somewhere It has Windows,
I also don't want to do things like downloading from the site, creating an installation file, I just want to access this program in any possible way through the embedded file itself, which is in the form of OLE Object and from the Packager Shell class. Write the object to a specific address or run it directly from Access itself
You can save the file as attachment in attachement field. If it will not accept an .exe file switch the extension and switch it back when exporting, you can do all this with code. Alternatively you can store the file as binary in an Ole field.

change of location of the database dynamically in app running

Try to make my app read the ms-access database from shortcut of my database it failed to read, so try to change the location of database dynamically ( there is an option in the app to move the database to drop-box folder and create a shortcut to that database in app folder )
try to make an shortcut to the moved ms-database
the app to read the database or to change the location of database dynamically
First of all, you should create a folder with a clear name in your VB.Net application path, namely inside the project Debug folder, let's name that folder as "MyProjFiles", so it will be in this path: ProjectFolderName\bin\Debug\MyProjFiles
Put your whole projects files inside our lovely folder MyProjFiles, including all types of your attachments: database, images, sounds, files, etc.
Call your database or whatever of those attachments files in addition to our \MyProjFiles\ using this method: My.Computer.FileSystem.CurrentDirectory & "\MyProjFiles\YourFilesPathHere.EXT".
Now, the whole path will be such as this string: "C:\CurrentUserNam\RootFolder\ProjectFolderName\bin\Debug\MyProjFiles\YourFilesPathHere.EXT"
For great practical example of this, supposuply let's open our MSAccessDB.accdb which is already copied into our project folder \MyProjFiles\ by this code directly:
System.Diagnostics.Process.Start(My.Computer.FileSystem.CurrentDirectory() & "\MyProjFiles\MSAccessDB.accdb")
The result will be simply opening our database which called "MSAccessDB.accdb"
Or open some pdf files such as this line:
System.Diagnostics.Process.Start(My.Computer.FileSystem.CurrentDirector() & "\MyProjFiles\MyPdfFile.pdf")
and so on.
I hope this can help you all brothers.
Best ^_^ Regards.
You should read this link.
It explains how to read the information you need to give the access Datareader something to do.
.NET read binary contents of .lnk file
Maybe this is enough, so you don't need to copy anything.

Print button didn't save the PDF file at a shared path, and no error logged

I have an Excel macro that uses SAP for printing data in pdf format.
Steps:
it access the SAP transaction which provides a table with the necessary information
it press Print button (from the Menu Bar of SAP)
then Print window appears (from here it is selected Microsoft Print To PDF option and then it is pressed OK button)
Save As window appears (complete the path and filename: \S\BC....\outputName)
then Save button it is pressed
then no error happens
But if I access the path folder "\S\BC....", nothing happen, there is no file saved. BUT, if we look in "Date modified" property of the folder, it is modified in accordance with the last saving time.
Also, I mention that if I'm trying to write the pdf file on local folders, not network shared folders (example: a desktop folder: C:\Users\mariah\Test), macro works.
Also, I mention that user can Read&Write at the shared path \S\BC....\
Please help me to find the cause of this issue.
A VBA macro only does what you are allowed to do manually. Can you manually save the file in the shared path without the macro?
Is the common path really \S\BC...\ or \ \S\BC...\ ?
Regards,
ScriptMan
Solution proposed by the OP in this comment:
IT WORKS if I save the file on "C:\Users\UserName" and then cut it to shared path "S\BC...". So I've implemented code that saves the file in a path and then copy it to another path and then I deleted it from the first path (such that user never knows that I copy the file in other destination than desired destination).

Replacing the default File copy Dialog

i'm trying to replace the default file copy dialog with my own program, which I want to create with vb.net.
My problem:
Where can I enter my application path to start automatically (and parse arguments/paths) when the user copies and/or pastes files?
Thanks in advance!
In order to monitor a file path I would suggest using FileSystemWatcher Class. This will monitor a folder for any files that are copied and pasted to the location. There is a great example at the below link.
https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(v=vs.110).aspx

Outlook VBA - How to unzip content

Background:
I have a script that iterates through emails (without any emails being selected) in an Outlook folder saving their attachments to the desktop.
Issue:
The attachment is a zip-file and I wonder if it is possible to save the decompressed file within (an .xls file) to the desktop instead?
Thank You!
The Outlook object model doesn't provide any method for that. You need to save the attached file on the disk and then unzip it programmatically.
If you try to use any search engine you can find the following links with a sample code:
VBA - Unzip files using VBA
Macro to Unzip Files - It's Just Creating Empty Folders
Unzip file(s) with the default Windows zip program (VBA)