简体   繁体   English

如何使用VSTO自动触发Outlook电子邮件中的链接

[英]how to automatically trigger a link in outlook email using VSTO

I'm trying to programmatically click on a link which creates an email with predefined subject,to,cc,bcc and body content of the email.My requirement is, If I select an Outlook mail item and click on “Approve via mail” in my Addin, the code will search for hyperlink “Click here to Approve” in the mail body and Automatically click on the hyperlink. 我试图以编程方式单击一个链接,该链接创建的电子邮件具有预定义的电子邮件的主题,主题,抄送,密件抄送和正文内容。我的要求是,如果我选择一个Outlook邮件项,然后在其中单击“通过邮件批准”我的插件,代码将在邮件正文中搜索“单击此处批准”超链接,然后自动单击超链接。 The hyperlink “Click here to Approve” creates an email with predefined subject,to,cc,bcc and body content of the email. 超链接“单击此处批准”将创建电子邮件,其中包含电子邮件的预定义主题,主题,抄送,密件抄送和正文内容。 I'm not sure how to do it with VSTO as all the other solutions suggest using JQuery and Javascript 我不确定如何使用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"))
        {

        }

I'm not sure what I can write in the IF segment of the code.Please Suggest. 我不确定我可以在代码的IF段中写什么。请提出建议。

Outlook doesn't provide anything for opening hyperlinks. Outlook不提供任何用于打开超链接的内容。 You can use the the following code ( Process.Start ) for opening them in the default web browser: 您可以使用以下代码( Process.Start )在默认的Web浏览器中打开它们:

Process.Start("your_hyperlink");

Or just create a Mail item progrmmatically in Outlook based on the info where the Approve button was clicked. 或者只是根据单击“批准”按钮的信息在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);
}

Take a look at the following articles for more information and samples: 请查看以下文章,以获取更多信息和示例:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用VSTO从Outlook中的通讯组列表获取电子邮件地址 - How to get email addresses from distribution list in outlook using VSTO 如何使用 VSTO Outlook 以编程方式将信息添加到 email? - How to add programmatically information to an email using VSTO Outlook? C# VSTO Outlook 插件 - 如何使用传出 Z0C83ZEFA57C7831CEB7B24 获取发送方的 email 地址? - C# VSTO Outlook plugin - How can I get the email address of the sender of an outgoing email using Exchange? 发送电子邮件之前使用VSTO添加到Outlook电子邮件收件人 - Adding to Outlook Email Recipient using VSTO before sending email Outlook插件-如何在VSTO中使用C#发送的电子邮件上设置“高重要性” - Outlook Addin - How can I set “High Importance” on email sent using C# in VSTO 如何为特定的Outlook VSTO插件触发OnRead事件? - How to trigger OnRead event for particular outlook VSTO addin? 如何在VSTO中打开Outlook电子邮件项目之前对其进行更改 - How to change Outlook email item before it openned in VSTO 如何在读取 email Outlook VSTO 时显示功能区 - How to display a Ribbon when reading an email Outlook VSTO VSTO - Outlook 如何从消息 ID 跟踪 email - VSTO - Outlook how to trace email from Message ID Outlook VSTO - 如何在 email 关闭时拦截它 - Outlook VSTO - How to intercept an email at the time of its closure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM