如何使用 Lotus c# (.Net) 打开新邮件
How to open a new mail with Lotus c# (.Net)
我目前正在用 C# 开发一个小应用程序。 Net 允许执行不同的任务,但在我的一项任务中,我必须从 Lotus 打开一个新的默认邮件。但是我没有找到太多关于它的文档,所以我有点迷路了,这就是我在你手中的原因:/
所以我只需要能够使用新的默认电子邮件打开 Lotus。
提前致谢 ;)
我建议您使用 selenium 网络驱动程序访问他们的 网站 并自动创建一个电子邮件帐户。
操作应用程序它本身可能非常复杂,您可以使用 .NET windows 输入模拟器 Nugat 包来模拟用户对应用程序的输入或直接写入内存使用 windows API.
我认为 Lotus 没有支持的方式来做到这一点。
但是如果你能用 Gmail 就有 Gmail API
https://developers.google.com/gmail/api/guides/
使用 .NET httpClient 与其交互。
并创建一个 Gmail 帐户
https://developers.google.com/admin-sdk/directory/v1/guides/manage-users
public void ComposeMemo(String sendto, String subject, String body)
{
//BLOC1 instantiate a Notes session and workspace
Type NotesSession = Type.GetTypeFromProgID("Notes.NotesSession");
Type NotesUIWorkspace = Type.GetTypeFromProgID("Notes.NotesUIWorkspace");
Object sess = Activator.CreateInstance(NotesSession);
Object ws = Activator.CreateInstance(NotesUIWorkspace);
//BLOC2 open current user's mail file
String mailServer = (String)NotesSession.InvokeMember("GetEnvironmentString", BindingFlags.InvokeMethod, null, sess, new Object[] { "MailServer", true });
String mailFile = (String)NotesSession.InvokeMember("GetEnvironmentString", BindingFlags.InvokeMethod, null, sess, new Object[] { "MailFile", true });
NotesUIWorkspace.InvokeMember("OpenDatabase", BindingFlags.InvokeMethod, null, ws, new Object[] { mailServer, mailFile });
Object uidb = NotesUIWorkspace.InvokeMember("GetCurrentDatabase", BindingFlags.InvokeMethod, null, ws, null);
Object db = NotesUIWorkspace.InvokeMember("Database", BindingFlags.GetProperty, null, uidb, null);
Type NotesDatabase = db.GetType();
//BLOC3 compose a new memo
Object uidoc = NotesUIWorkspace.InvokeMember("ComposeDocument", BindingFlags.InvokeMethod, null, ws, new Object[] { mailServer, mailFile, "Memo", 0, 0, true });
Type NotesUIDocument = uidoc.GetType();
NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "EnterSendTo", sendto });
NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "Subject", subject });
NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "Body", body });
//BLOC4 bring the Notes window to the front
String windowTitle = (String)NotesUIDocument.InvokeMember("WindowTitle", BindingFlags.GetProperty, null, uidoc, null);
Interaction.AppActivate(windowTitle);
}
BLOC1 执行,它打开了应用程序,但是从 BLOC2 应用程序不再响应,但我不知道为什么,而且在 BLOC4 中无法识别 Interaction
我目前正在用 C# 开发一个小应用程序。 Net 允许执行不同的任务,但在我的一项任务中,我必须从 Lotus 打开一个新的默认邮件。但是我没有找到太多关于它的文档,所以我有点迷路了,这就是我在你手中的原因:/ 所以我只需要能够使用新的默认电子邮件打开 Lotus。 提前致谢 ;)
我建议您使用 selenium 网络驱动程序访问他们的 网站 并自动创建一个电子邮件帐户。
操作应用程序它本身可能非常复杂,您可以使用 .NET windows 输入模拟器 Nugat 包来模拟用户对应用程序的输入或直接写入内存使用 windows API.
我认为 Lotus 没有支持的方式来做到这一点。
但是如果你能用 Gmail 就有 Gmail API https://developers.google.com/gmail/api/guides/ 使用 .NET httpClient 与其交互。 并创建一个 Gmail 帐户 https://developers.google.com/admin-sdk/directory/v1/guides/manage-users
public void ComposeMemo(String sendto, String subject, String body)
{
//BLOC1 instantiate a Notes session and workspace
Type NotesSession = Type.GetTypeFromProgID("Notes.NotesSession");
Type NotesUIWorkspace = Type.GetTypeFromProgID("Notes.NotesUIWorkspace");
Object sess = Activator.CreateInstance(NotesSession);
Object ws = Activator.CreateInstance(NotesUIWorkspace);
//BLOC2 open current user's mail file
String mailServer = (String)NotesSession.InvokeMember("GetEnvironmentString", BindingFlags.InvokeMethod, null, sess, new Object[] { "MailServer", true });
String mailFile = (String)NotesSession.InvokeMember("GetEnvironmentString", BindingFlags.InvokeMethod, null, sess, new Object[] { "MailFile", true });
NotesUIWorkspace.InvokeMember("OpenDatabase", BindingFlags.InvokeMethod, null, ws, new Object[] { mailServer, mailFile });
Object uidb = NotesUIWorkspace.InvokeMember("GetCurrentDatabase", BindingFlags.InvokeMethod, null, ws, null);
Object db = NotesUIWorkspace.InvokeMember("Database", BindingFlags.GetProperty, null, uidb, null);
Type NotesDatabase = db.GetType();
//BLOC3 compose a new memo
Object uidoc = NotesUIWorkspace.InvokeMember("ComposeDocument", BindingFlags.InvokeMethod, null, ws, new Object[] { mailServer, mailFile, "Memo", 0, 0, true });
Type NotesUIDocument = uidoc.GetType();
NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "EnterSendTo", sendto });
NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "Subject", subject });
NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "Body", body });
//BLOC4 bring the Notes window to the front
String windowTitle = (String)NotesUIDocument.InvokeMember("WindowTitle", BindingFlags.GetProperty, null, uidoc, null);
Interaction.AppActivate(windowTitle);
}
BLOC1 执行,它打开了应用程序,但是从 BLOC2 应用程序不再响应,但我不知道为什么,而且在 BLOC4 中无法识别 Interaction