[英]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.