DLLImportAttribute C#-Outlook [英] DLLImportAttribute C# - Outlook

查看:269
本文介绍了DLLImportAttribute C#-Outlook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C#代码开发一个片段,以启用Outlook的投票选项"功能.

此代码将被称为Blue Prism的平台使用.

Outlook的投票"功能位于Microsoft.Office.Interop.Outlook命名空间中,因此我需要使用C#导入它,但是我没有足够的知识来开发它.

我试图做这样的事情,但是它给出了一个错误. 这是代码:

public class program {

[DllImport(@"C:\Program Files\Blue Prism Limited\Blue Prism Automate\Microsoft.Office.Interop.Outlook.dll", EntryPoint = "VotingOptions")]
public static extern string Outlook(uint type);

static void Main()
{
    // Create the Outlook application.
    Outlook.Application  oApp = new Outlook.Application();
oApp.VotingOption = "Yes; No";
}

}

那么,有人可以帮助我吗?

解决方案

如果您使用的是Blue Prism,则不必指定DLL引用,也可以选择采用GetObjectCreateObject的方式,能够与Outlook交互,就像Blue Prism与Excel一样.这种方法的缺点是您必须使用VB.NET(除非我没有记错),并且您将无法使用枚举值的文本表示(因此对于

This code will be used by a platform called Blue Prism.

The "vote" function of Outlook is in the Microsoft.Office.Interop.Outlook namespace, so I need to import it using C#, but I dont have enough knowledge to develop this.

I tried to do something like this but it is giving an error. Here is the code:

public class program {

[DllImport(@"C:\Program Files\Blue Prism Limited\Blue Prism Automate\Microsoft.Office.Interop.Outlook.dll", EntryPoint = "VotingOptions")]
public static extern string Outlook(uint type);

static void Main()
{
    // Create the Outlook application.
    Outlook.Application  oApp = new Outlook.Application();
oApp.VotingOption = "Yes; No";
}

}

So, can someone help me?

解决方案

If you are using Blue Prism then rather than having to specify DLL references you may also chose to go the GetObject or CreateObject way, you will be able to interact with Outlook just like Blue Prism does with Excel. The drawback of this approach is that you have to use VB.NET (unless I am mistaken) and that you will not be able to use text representation of enum values (so for OlItemType you will not be able to use olMailItem but only its numeric value, which is 0).

Please note that Blue Prism has released a new version recently (6.3) and with it a new VBO for interaction with Outlook. It's nothing revolutionary, but it may provide some insight.

这篇关于DLLImportAttribute C#-Outlook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆