如何使用 VSTO 在 outlook 电子邮件中自动触发 link

how to automatically trigger a link in outlook email using VSTO

我正在尝试以编程方式单击 link,它会创建一封电子邮件,其中包含预定义的主题、收件人、抄送、密件抄送和 email.My 要求的正文内容,如果我 select 一个 Outlook 邮件项目并单击我的插件中的“通过邮件批准”,代码将在邮件正文中搜索 hyperlink“单击此处批准”并自动单击 hyperlink . hyperlink“点击此处批准”创建一封电子邮件,其中包含电子邮件的预定义主题、收件人、抄送、密件抄送和正文内容。 我不确定如何使用 VSTO 执行此操作,因为所有其他解决方案都建议使用 JQuery 和 Javascript

Object selObject = this.Application.ActiveExplorer().Selection[1];
        Outlook._MailItem eMail = (Outlook._MailItem)
        this.Application.CreateItem(Outlook.OlItemType.olMailItem);
        eMail = ((Outlook._MailItem)selObject);
        if(eMail.HTMLBody.Contains("Approve"))
        {

        }

我不确定我可以在 code.Please 建议的 IF 段中写什么。

Outlook 不提供任何用于打开超链接的功能。您可以使用以下代码 (Process.Start) 在默认网络浏览器中打开它们:

Process.Start("your_hyperlink");

或者只是根据单击“批准”按钮的信息在 Outlook 中以编程方式创建邮件项目。

 Outlook.MailItem mail = null;
Outlook.Recipients mailRecipients = null;
Outlook.Recipient mailRecipient = null;
try
{
    mail = OutlookApp.CreateItem(Outlook.OlItemType.olMailItem)
       as Outlook.MailItem;
    mail.Subject = "A programatically generated e-mail";
    mailRecipients = mail.Recipients;
    mailRecipient = mailRecipients.Add("Eugene Astafiev");
    mailRecipient.Resolve();
    if (mailRecipient.Resolved)
    {
        mail.Send();
    }
    else
    {
        System.Windows.Forms.MessageBox.Show(
            "There is no such record in your address book.");
    }
}
catch (Exception ex)
{
    System.Windows.Forms.MessageBox.Show(ex.Message,
        "An exception is occured in the code of add-in.");
}
finally
{
    if (mailRecipient != null) Marshal.ReleaseComObject(mailRecipient);
    if (mailRecipients != null) Marshal.ReleaseComObject(mailRecipients);
    if (mail != null) Marshal.ReleaseComObject(mail);
}

查看以下文章以获取更多信息和示例: