I can use “Get Outlook Mail Messages” to get an email from outlook.
My question is how to open this mail in outlook?
There seems not having activity such as “Open email” …
Hi,
Can you also share what you want to do after “Open Email”? It may be able to achieve it inside UiPath without opening the email.
Regards,
@Yoichi “Open Email” is to show user the email instead of click to open this email manually.
User will continue do their job on this mail say attach a file.
It is kickoff by a trigger when they click certain button on the webpage.
But I can not find a way to open this mail.
Thank you!
Hi,
As far as I know, there is no specific activity to open mail window in Desktop Outlook.
We can achieve it using UiAutoamtion such as Click, Keyboard shortcut etc.
For example, if it’s necessary to open new blank mail window, Ctrl+N will help you.
OR, as more advanced way, we can also achieve it using Microsoft.Office.Interop.Outlook.
Regards,
I get it work by using Microsoft.Office.Interop.Outlook
below is the c# code :
public static void OpenNewMail_in_Outlook()
{
Microsoft.Office.Interop.Outlook.Application outlookApp = null;
MailItem mailItem = null;
try
{
// 创建一个Outlook应用程序实例
outlookApp = new Microsoft.Office.Interop.Outlook.Application();
// 创建一个新的邮件项
mailItem = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);
// 设置邮件的接收者
mailItem.Recipients.Add("example@example.com");
// 设置邮件的主题
mailItem.Subject = "这是邮件的主题";
// 设置邮件的正文
mailItem.HTMLBody = "<p>啊这是一个HTML格式的邮件正文。</p><p>点击这里访问<a href=\"http://www.baidu.com\">百度</a>。</p>"; // "这是邮件的正文内容";
//mailItem.BodyFormat=OlBodyFormat.olFormatHTML;
// 显示邮件窗口
mailItem.Display(false); // 参数表示是否以模态方式显示窗口
}
catch (System.Runtime.InteropServices.COMException ex)
{
Console.WriteLine("无法创建或显示Outlook邮件: " + ex.Message);
System.Diagnostics.Debug.WriteLine("无法创建或显示Outlook邮件: " + ex.Message);
}
catch (System.Exception ex)
{
Console.WriteLine("发生了一个异常: " + ex.Message);
System.Diagnostics.Debug.WriteLine("发生了一个异常: " + ex.Message);
}
finally
{
// 释放资源
if (mailItem != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(mailItem);
}
if (outlookApp != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(outlookApp);
}
// 强制垃圾回收器清理
GC.Collect();
GC.WaitForPendingFinalizers();
}
}

