Question
virtusapolaris
IN
Last activity: 19 May 2017 10:35 EDT
How to download a new mail from outlook to user specified location in Openspan
Is there OpenSpan automation to download the new outlook mail and save it in a user specified folder.
***Updated by Moderator: Marissa to update categories***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
US
It is actually pretty simple to do, you just need to understand a little about the object model. When Pega Robotics raises a NewMail event it returns a MicrosoftOutlookMail object which contains the email. This is a wrapper for an Outlook MailItem. The MailItem is available using the OutlookMail property of the MicrosoftOutlookMail object. The MailItem object has a SaveAs method which you can use to save the email. The trick here is that SaveAs requires a OlSaveAsType as a parameter which tells it which format to use when saving. There is no way to directly create that parameter so we use a little trick. Create a jump label and add a parameter of the type Microsoft.Office.Interop.Outlook.OlSaveAsType. Here is a screen shot of the completed automation, which is very small and pretty easy to understand once you know just a little about the object model.
Pegasystems Inc.
US
Iak,
An example of how to do so can be found in the post below.
virtusapolaris
IN
Thomz,
I have to save the mail in .msg to a user specified location,not only the attachement.
Pegasystems Inc.
US
Iak,
Microsoft Office Connectors only allow you to save instances of emails that were created through automation into your draft folder and not pre-exisitng emails to a user specified location. If you wish to save in that type of manner you will need to create a custom script referencing the Microsoft.InterOp.Office.Outlook namespace to do so.
virtusapolaris
IN
Hi Thomz,
I am not aware of the .NET code,where can I get that Script code.
Pegasystems Inc.
US
There isn't a pre-saved script that we provide to Robotics developers. You will need to search how to implement this through c# code online. But in doing so you will need to reference the Microsoft.Office.Interop.Outlook namespace using the Microsoft.Office.Interop.Outlook.dll.
You also likely need to call the mailItem.savas method to save the email to a specified folder. Below is a link to details of the method to get you started
Accepted Solution
Pegasystems Inc.
US
It is actually pretty simple to do, you just need to understand a little about the object model. When Pega Robotics raises a NewMail event it returns a MicrosoftOutlookMail object which contains the email. This is a wrapper for an Outlook MailItem. The MailItem is available using the OutlookMail property of the MicrosoftOutlookMail object. The MailItem object has a SaveAs method which you can use to save the email. The trick here is that SaveAs requires a OlSaveAsType as a parameter which tells it which format to use when saving. There is no way to directly create that parameter so we use a little trick. Create a jump label and add a parameter of the type Microsoft.Office.Interop.Outlook.OlSaveAsType. Here is a screen shot of the completed automation, which is very small and pretty easy to understand once you know just a little about the object model.
virtusapolaris
IN
It helped me a lot.Thank you so much jeffbadger.
Comptech Associates Inc
US
This is great! Adding a list of the types to assist in searching as I tried first to search on olMSG and got nothing...
Can be one of the following OlSaveAsType constants: olHTML, olMSG, olRTF, olTemplate, olDoc, olTXT, olVCal, olVCard, olICal, or olMSGUnicode.