Table of Contents
- Overview
- Glossary
- Installation
- Tutorials
- Scenario Steps
- Advanced
- Application
- Screen Data
- Verification
- Clipboard
- Comparison
- Culture
- Data Source
- Date Time
- Driver
- Excel
- FTP
- File
- Flow Control
- Folder
- Format and Conversion
- Keyboard
- Loops
- Math
- Random
- Regex
- Screen
- System
- Text
- User Interface
- Windows Account Information
- Expression Development
- Embedded Development Environment
- Voodoo Connect
- Cross-Browser Scripting (CBS)
- Chrome Extension
- Firefox Extension
- Notification Center
- Unified Console
- Wrapper Libraries
- Database
- Troubleshooting
- 3rd Party Tool
Use of EAGetMail Library in The Voodoo RPA Program
If you have used the email listening step in your processes, it saves the incoming e-mails in the file you specified in .eml format. If you want to receive attachment, CC, Mail to, Subject etc. from the e-mail, you need to use the “EAGetMail” library.
-
- Steps to be followed when using:
1. You can manually download this library from here and add it to your EDE file references.
2. !Directory.GetFiles(“”)= The file path you specified in the email listening step. (file with .eml files)
3. !oMail.SaveAs(“”)= File path to save parsed files.
Example #1
The following example codes demonstrate parsing email (*.EML) file.
namespace VoodooImplementation { using System; using VooDooCommonData.CommonInterface; using VooDooCommonData.InstanceData; using EAGetMail; using System.IO; public class ComputationEvaluator : System.MarshalByRefObject, IPlugInComputation { private bool result_; private VooDooCommonData.InstanceData.PlanDataInstanceManager planDataInstanceManager_; /// Default Constructor for class public ComputationEvaluator() { } public bool result { get { return result_; } } public virtual VooDooCommonData.InstanceData.PlanDataInstanceManager planDataInstanceManager { get { return planDataInstanceManager_; } set { planDataInstanceManager_ = value; } } /// Calculate public virtual void ExecuteComputation() { try { string[] files = Directory.GetFiles("C:\\Mail\\", "*.eml"); for (int i = 0; i < files.Length; i++) { ParseEmail(files[i]); File.Delete(files[i]); } result_ = true; } catch (Exception ep) { using (StreamWriter file = File.AppendText(@"C:\Users\OneZero\Desktop\Test.txt")) { file.WriteLine(DateTime.Today.ToString("dd.MM.yyyy HH:mm:ss") + "\t" + ep); } } } static void ParseEmail(string emlFile) { Mail oMail = new Mail("TryIt"); oMail.Load(emlFile, false); Attachment[] atts = oMail.Attachments; for (int i = 0; i < atts.Length; i++) { Console.WriteLine("Attachment: {0}", atts[i].Name); if(atts[i].Name.Contains(".xlsx") || atts[i].Name.Contains(".XLSX") ) oMail.SaveAs(@"C:\Users\OneZero\Downloads\" + atts[i].Name, true); } // Parse Mail From, Sender Console.WriteLine("From: {0}", oMail.From.ToString()); // Parse Mail To, Recipient MailAddress[] addrs = oMail.To; for (int i = 0; i < addrs.Length; i++) { Console.WriteLine("To: {0}", addrs[i].ToString()); } // Parse Mail CC addrs = oMail.Cc; for (int i = 0; i < addrs.Length; i++) { Console.WriteLine("To: {0}", addrs[i].ToString()); } // Parse Mail Subject Console.WriteLine("Subject: {0}", oMail.Subject); // Parse Mail Text/Plain body Console.WriteLine("TextBody: {0}", oMail.TextBody); // Parse Mail Html Body Console.WriteLine("HtmlBody: {0}", oMail.HtmlBody); } } }