Exchange Web Services in BP using C#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
28-10-19 01:34 PM
I am trying to develop a BP C# object that uses Exchange Web Services (EWS). I have written a working code in Visual Studio but I am struggling to make in work in Object Studio.
This is the code from Visual Studio:
using Microsoft.Exchange.WebServices.Data;
using System;
using System.Net;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
ExchangeService service = new ExchangeService();
service.Credentials = new NetworkCredential("userid", "password");
service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "userid");
Folder inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
Console.WriteLine($"Unread email in inbox: {inbox.UnreadCount}");
Console.ReadLine();
}
}
}
My code stage in Object Studio looks like this:
I have copied the Microsoft.Exchange.WebServices DLL to C:\Program Files\Blue Prism Limited\Blue Prism Automate\, and added Microsoft.Exchange.WebServices.dll and System.Net.dll to External References and Microsoft.Exchange.WebServices.Data and System.Net to Namespace Imports.
I get the following errors:
Can anyone see what I am doing wrong? I realize that the code stage errors are syntax related, but I won't be able to fix those until the namespace error is resolved, which I have no clue how to fix.
Thank you very much in advance!
------------------------------
Christian Juhl
Business Controller
Danske Commodities
Europe/Copenhagen
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
28-10-19 03:12 PM
Try the namespaces given below.
------------------------------
Jerin Jose
RPA Product SME
EY
Asia/Kolkata
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
28-10-19 04:32 PM
Have you developed any EWS objects i Blue Prism that you would be willing to share?
------------------------------
Christian Juhl
Business Controller
Danske Commodities
Europe/Copenhagen
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
29-10-19 06:50 AM
https://github.com/aikudinov/BlueprismVBO/blob/master/BPA%20Object%20-%20Exchange%20EWS%20API.xml
Search filter need to be redone - AQS searches are cached, but you can't reset it in managed api - not useable.
Using generic SearchFilter will be either limited or overcomplicated - I can just provide both options I guess.
There is only basic mail. Appointments etc are not hard, but don't have spare time to work on it.
Not sure if url autodiscovery will work with office365..
If you drop dlls in Automate folder instead of installing from msi - remove paths to dlls in the VBO.
Should get you started ...
p.s. About your code: you don't need program/main - code stage is basically a static function within a class (VBO). There is also no console. You also need to define your service in globals if you want to use multiple code stages.
------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
29-10-19 10:35 AM
------------------------------
Christian Juhl
Business Controller
Danske Commodities
Europe/Copenhagen
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
29-10-19 11:18 AM
However, if you want to create a generic VBO with multiple actions, you will either have to do initialization (ExchangeService service = new ExchangeService(); etc..) in each code stage, or you go in Initialization page (where you add dll references) - Global code and declare "ExchangeService service; " there, then use "service = new ExchangeService();" when you actually do init in a code stage.
This way that service variable will be persistent across different code stages within VBO (during process lifetime) and you'd only have to do init once.
------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-11-19 09:05 AM
------------------------------
Pratyush Garikapati
ROM Architect
Blue Prism
Asia/Kolkata
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-11-19 02:08 PM
------------------------------
Christian Juhl
Business Controller
Danske Commodities
Europe/Copenhagen
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-11-19 02:10 PM
------------------------------
Christian Juhl
Business Controller
Danske Commodities
Europe/Copenhagen
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
06-11-19 03:24 AM
I also just learned about the Exchange Functions VBO that Agilify made. It's mostly working for me as well, but did you find that the Search Folder action seems to ignore the Folder ID input?
I use the actions in this order:
1. Setup Service Office 365 -- works for me (not using Impersonated User ID)
2. Search Folder ID By Name -- seems to work since it returns a folder ID consistently and can even return folder IDs from shared mailboxes if I input the shared mailbox address in Alternate Mailbox Address.
3. Search Folder -- this seems to always return the Inbox, and I'm not sure but I think maybe it has something to do with the code seeming to bind arbitrarily to the inbox. However, this will throw an error if I provide no Folder ID, and it will still return the Inbox items if I provide a random value. So, it appears as though the code completely ignores the Folder ID.
Anyway, anyone else having the same result? I may attempt to edit the code, but it's annoying because it's code that is compiled into DLLs.
------------------------------
Dave Morris
3Ci @ Southern Company
Atlanta, GA
------------------------------
Dave Morris, 3Ci at Southern Company
