Microsoft OutlookMail Connector Save Method

We have an automation that requires to loop through the outlook folder, read each details and save each email as *.MSG file.

So far what we are able to achieve is to retrieve the emails from a folder (Mail Collection) and loop through by index to get the details. We are able to find a Save method under the Mail Item proxy. This runs smoothly, no runtime error, but we can seems to find the saved email.

Is there a default folder where the email is being saved and download, is that folder can be altered to cater the process needs?

Attached is the sample automation that we have.

Thanks!

@rnikkoprado Save actually saves the mail into Outlook. You want to save it to disk. To do that, you need the SaveAs method. This exists on the actual Outlook MailItem. You can access this from ObjectExplorer.

  1. Select your “mailItem” proxy object in Object Explorer,
  2. Click the icon in the upper right area of the window labelled “Explore Component Properties”.
  3. Locate the “OutlookMail” item and select it.
  4. Select the SaveAs method from this item and drag it into your automation.
  5. You can now click the are from step 2, however now the icon will be labelled “Explore Components” to return to the previous view.
  6. The SaveAs method takes two parameters.
    • The first is the path to where and what file name you wish to save the messages as (C:\Temp\MyMessage.msg" for example).
    • The second is an enum value corresponding to the list below. The easiest way is just to pass it an integer corresponding to the option you prefer (likely a 3).

https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.outlook.olsaveastype?view=outlook-pia

@ThomasSasnett If you would like to select the Save As type instead of passing it an an integer, you may do so with a Jump Label. The method accepts an object, however the exact type is Microsoft.Office.Interop.Outlook.OlSaveAsType. To get this in your automation, you can create a Jump Label and add a parameter. Then select Browse on the data type column and select Microsoft.Office.Interop.Outlook.OlSaveAsType as shown in the screenshot. Now, when you jump to this label, you can select the type from a drop-down list rather than having to know the exact numerical value.

@ThomasSasnett Thanks Thomas for the detailed explanation! I got it working smoothly.

@ThomasSasnett Hello Thomas, Just a follow-up, the solution you suggested is working but currently is on intermitent and we are encountering Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) in the MailItem.SaveAs() method.

What should we do in order to make a consistent run?

MicrosoftTeams-image.png

@rnikkoprado I am not sure what that error might refer to. I would suggest opening a support request as our team can take a look at logs with you.