Consider the following code:
using Microsoft.Office.Interop.Outlook;
using OutlookApp = Microsoft.Office.Interop.Outlook.Application;
namespace OutlookInterop
{
class Program
{
static void Main(string[] args)
{
OutlookApp outlookApp = new OutlookApp();
MailItem mailItem = outlookApp.CreateItem(OlItemType.olMailItem);
mailItem.To = "test@test.com";
mailItem.Subject = "Test Email Alert";
mailItem.HTMLBody = "<html><body>Test email body.</body></html>";
mailItem.Display(false);
}
}
}
This code works fine when I run it on Visual Studio, but when I use it in BluePrism, I get the following compiler error:
Page: Send Email Alert c#
Stage: Code1
Type: Error
Action: Validate
Description: Compiler error at line 2: Cannot implicitly convert type 'object' to 'Microsoft.Office.Interop.Outlook.MailItem'. An explicit conversion exists (are you missing a cast?)
Repairable: No
I think I have referenced the correct assemblies in BluePrism i.e.:
And then this is the code inside the actual code stage:
OutlookApp outlookApp = new OutlookApp();
MailItem mailItem = outlookApp.CreateItem(OlItemType.olMailItem); //this would be line 2
mailItem.To = "test@test.com";
mailItem.Subject = "Test Email Alert";
mailItem.HTMLBody = "<html><body>Test email body.</body></html>";
mailItem.Display(false);
So, why would that code work on Visual Studio but not in BluePrism? what is this cast that is missing?