cancel
Showing results for 
Search instead for 
Did you mean: 

Saving Outlook emails

JamesBarrett
Level 4
I was wondering whether anyone has developed an object action to Save emails / Move emails to a network folder? I'll look at trying to create one if not, but I'm not an expert with VBA. The Move Email action within the MAPIEx VBO appears to be limited to moving files to other folders within Outlook. I have heard there may be a potential enhancement to incorporate Save Mail in future, but not sure of timescales. Has anyone developed something already that I could have a look at? Thanks James
18 REPLIES 18

SumanMahato
Level 2
Hi James, Hope you are doing good. I have a process requirement which is similar to this. Where automation need to send a mail and save the mail in a network folder. I have created a BO for outlook operation . In save email operation the first action should be search the mail. The mail sent by automation has an unique case id in the mail subject . In save email action first task is to search the mail. So first i opened the sent mail box in outlook profile then put the unique id in search bar and press enter. the first mail in the list of result will be selected. Next action is to click on the ""save as ""icon in outlook application . When it was clicked an windows dialog box opened. Select the file type as Outlook unicode text and chose a folder. then click on save button. The mail will be saved in the network folder. I will add the BO details once the testing will be completed.

TomBlackburn1
Level 7
If you use the SMTP/POP3 object, you can actually configure and SMTP client to send emails to the filesystem: stackoverflow.com/questions/1264672/how-to-save-mailmessage-object-to-disk-as-eml-or-msg-file

Anonymous
Not applicable
Hi James, I looked at writing some code for a client of mine that would do exactly this: Public Sub saveAttachtoDisk (itm As Outlook.MailItem) Dim objAtt As Outlook.Attachment Dim saveFolder As String saveFolder = "c:\temp For Each objAtt In itm.Attachments objAtt.SaveAsFile saveFolder & ""\" & objAtt.DisplayName Set objAtt = Nothing Next End Sub The above VB would save the attachment to a specified folder however the requirement on this one would be triggered via and Outlook Mail rule. I'm sure you could look into what would be the best solution for your circumstances but at you have the code above to at least play around with. Let me know if you have any questions and I'll do what I can to help. Thanks Jimmy

Anonymous
Not applicable
Hi all, I work with James on the same project. We are using Outlook 2010 and MAPIEx. We are currently spying Outlook to do this how a user would re: interacting with Outlook, but would prefer an object similar to the Move Mail. We'll also be asking Blue Prism to add this to their enhancements list, as our thoughts are that the Move Mail object could be used for both moving mails to other email folders OR to a network drive with a bit of tweaking to their code. We'll have a look at a couple of the suggestions to see what we can work with in the interim. Thanks

ShreyansNahar
Level 5
Hi Paul, Regarding the Move mail function, I think MapieX module of Blue Prism helps in doing that when you try to Get Email from Inbox.

RadoslavHiko
Level 4
You can use this code in a BP code stage. You will have to import Microsoft.VisualBasic and System.IO namespaces for this to work. Inputs: sEmailID (Text) - ID of the email in Outlook, sPath (Text) - where you want to save it, nFormat (Number) - format of the saved message (see the code for possible values) Outputs: [none] Code: Dim sFileName As String Dim olApp As Object Dim olNameSpace As Object Dim olEmail As Object olApp = CreateObject(""Outlook.Application"") olNameSpace = olApp.GetNamespace(""MAPI"") olEMail = olNameSpace.GetItemFromID(sEmailID) Select Case nFormat Case 0 sFileName = olEmail.Subject & "".txt"" Case 1 sFileName = olEmail.Subject & "".rtf"" Case 3, 9 sFileName = olEmail.Subject & "".msg"" Case 5 sFileName = olEmail.Subject & "".htm"" Case Else sFileName = olEmail.Subject & "".msg"" nFormat = 3 End Select For Each invalidChar As Char In IO.Path.GetInvalidFileNameChars sFileName = sFileName.Replace(invalidChar , """") Next olEmail.SaveAs(sPath & ""\ & sFileName nFormat)

Hello Radoslav, I am trying to use the code you have provided but so far I was not successful (getting error msg: ""Exception thrown by code stage: Could not open the item. Try again""). The main issue is in my opinion in used ID. Could you probably specify what kind of ID does the use? What folder should it be in? I have tried direct ID extracted (manualy) from outlook but did not work. Thank you.

Hi,

do you find any solution to save mail? We cannot open Outlook client, so for example we want to use "email pop3 smtp" object.

Thanks, Nicolò



------------------------------
Nicolò Ceccaroni
------------------------------

So you just need to be able to save emails as files, but you need to do it with something other than the standard Outlook VBO?

Cheers,



------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------