cancel
Showing results for 
Search instead for 
Did you mean: 

Exchange Web Services in BP using C#

ChristianJuhl
Level 4
Hi,

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:

29318.png

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:

29320.png

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
------------------------------
15 REPLIES 15

Hi Dave,

Would you be able to give this feedback on the asset page (same link I shared above)? The developers can review and provide feedback/fixes accordingly.

------------------------------
Pratyush Garikapati
ROM Architect
Blue Prism
Asia/Kolkata
------------------------------

Are you referring to 'Add your review'? I can add a note there if so. It seems like that is for giving my thoughts about the VBO, but it doesn't seem like the appropriate place for reporting possible bugs with the code.

Hmm... There needs to be an easy way to send a message to the owner of the asset.

------------------------------
Dave Morris
3Ci @ Southern Company
Atlanta, GA
------------------------------

Dave Morris, 3Ci at Southern Company

Yes, I was referring to 'Add your review'. You can also post a message in the DX Community page.

------------------------------
Pratyush Garikapati
ROM Architect
Blue Prism
Asia/Kolkata
------------------------------

You might want to mention, they are using regex to filter out HTML from email, while you can actually ask server to return text:
PropertySet properties = new PropertySet(BasePropertySet.FirstClassProperties,...);
properties.RequestedBodyType = BodyType.Text; // pretty please!!
EmailMessage email = EmailMessage.Bind(service, (ItemId)Id, properties);

But maybe they are doing it intentionally...

------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------

Hi Dave,

Did you find a solution to this problem? I am experiencing the exact same issue. It looks like the DX page was updated on 11/19/2019 but the downloadable version is still 1.1.

------------------------------
Christian Juhl
Business Controller
Danske Commodities
Europe/Copenhagen
------------------------------

Nah, I didn't find a solution for it. I ended up deciding not to use the object in production. Instead, we'll probably just go to GRAPH API when I have time to set it up.

------------------------------
Dave Morris
3Ci @ Southern Company
Atlanta, GA
------------------------------

Dave Morris, 3Ci at Southern Company