Does anyone have a sample where when a user sends an email from outlook a question is asked "Do you want to save to M-files? Yes or No"
If the user clicks yes the save/properties window is displayed
;D
The M-Files Community will be updated on Tuesday, April 2, 2024 at 10:00 AM EST / 2:00 PM GMT and the update is expected to last for several hours. The site will be unavailable during this time.
The organization also may want to save important sent e-mail to M-Files. Such important messages could be, e.g., proposals and confirmation of orders. The organization can create a new archive e-mail account to which M-Files is connected. From this box M-Files imports all e-mail to the document vault and then deletes the messages from the mail server. Important sent messages can be archived in M-Files by sending the message to the archive box by means of the Cc or Bcc fields. To avoid junk mail, it is possible to set the e-mail account to accept mail from internal users only.
I think it can be done with an office macro but need to do some research
Take a look at the Microsoft webpage for MS Exchange Journaling and evaluate if it suits your needs.
Option Explicit
' Triggered when an e-mail is sent.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
' Error handling.
On Error GoTo ErrorHandling
' Test and get an interface to the email item.
If Not TypeOf Item Is Outlook.MailItem Then
Exit Sub
End If
Dim emailItem As Outlook.MailItem
Set emailItem = Item
' Prompt for save.
If MsgBox("Save the message to M-Files?", vbYesNo Or vbMsgBoxSetForeground) = vbNo Then
Exit Sub
End If
' Get the M-Files client application interface and the vault connection.
' Note: fixed vault name.
Dim clientApp As New MFilesAPI.MFilesClientApplication
Dim vaultConnection As MFilesAPI.vaultConnection
Set vaultConnection = clientApp.GetVaultConnection("Sample")
' Bind and log in to the vault.
Dim vault As MFilesAPI.vault
Set vault = vaultConnection.BindToVault(0, True, True)
If vault Is Nothing Then GoTo Cancelled
' Create file classes for supported file formats.
Dim objectFileClasses As New MFilesAPI.FileClasses
objectFileClasses.Add -1, New MFilesAPI.FileClass
objectFileClasses(1).LoadByExtension "msg"
' Build ObjectCreationInfo for the metadata card with file class selector.
' In order to keep this simple, pretty much all editing is denied.
Dim objCreationInfo As New MFilesAPI.objectCreationInfo
objCreationInfo.SetTitleAsDatatypeText emailItem.Subject, True
objCreationInfo.SetObjectType MFilesAPI.MFBuiltInObjectTypeDocument, False
objCreationInfo.SetSingleFileDocument True, False
objCreationInfo.SetSelectableFileClasses objectFileClasses
objCreationInfo.SetSelectedFileClass objectFileClasses(1), False
objCreationInfo.SetExtension "msg", False
' Disable object creation because we will create it by ourselves later.
objCreationInfo.SetDisableObjectCreation True
' Display the metadata card for new object
Dim objWindowResult As MFilesAPI.objectWindowResult
Set objWindowResult = vault.ObjectOperations.ShowNewObjectWindow( _
0, MFObjectWindowModeInsertSaveAsType, objCreationInfo)
If objWindowResult.result = MFObjectWindowResultCodeCancel Then GoTo Cancelled
' Create new single-file document with empty file.
' Use properties provided by the metadata card to fill the object's metadata.
Dim objVersionAndProperties As MFilesAPI.objectVersionAndProperties
Set objVersionAndProperties = vault.ObjectOperations.CreateNewEmptySingleFileDocument( _
objWindowResult.Properties, _
objWindowResult.Properties.SearchForProperty(MFBuiltInPropertyDefNameOrTitle).GetValueAsUnlocalizedText, _
objWindowResult.SelectedFileClass.Extension)
' Resolve the path to the newly-created empty document file.
Dim path As String
Let path = vault.ObjectFileOperations.GetPathInDefaultView( _
objVersionAndProperties.ObjVer.ObjID, _
objVersionAndProperties.ObjVer.Version, _
objVersionAndProperties.VersionData.Files(1).FileVer.ID, _
objVersionAndProperties.VersionData.Files(1).FileVer.Version)
' Save the e-mail over the empty file.
emailItem.SaveAs path
' Check in right away, unless we are in offline mode.
If vault.ClientOperations.IsOnline Then
vault.ObjectOperations.CheckIn objVersionAndProperties.ObjVer
End If
Exit Sub
' Error handling.
ErrorHandling:
MsgBox Err.Description
Exit Sub
' Cancellation.
Cancelled:
Cancel = True
emailItem.Display
Exit Sub
End Sub