[英]How to get email addresses from distribution list in outlook using VSTO
[英]how to automatically trigger a link in outlook email using VSTO
我试图以编程方式单击一个链接,该链接创建的电子邮件具有预定义的电子邮件的主题,主题,抄送,密件抄送和正文内容。我的要求是,如果我选择一个Outlook邮件项,然后在其中单击“通过邮件批准”我的插件,代码将在邮件正文中搜索“单击此处批准”超链接,然后自动单击超链接。 超链接“单击此处批准”将创建电子邮件,其中包含电子邮件的预定义主题,主题,抄送,密件抄送和正文内容。 我不确定如何使用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"))
{
}
我不确定我可以在代码的IF段中写什么。请提出建议。
Outlook不提供任何用于打开超链接的内容。 您可以使用以下代码( Process.Start )在默认的Web浏览器中打开它们:
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);
}
请查看以下文章,以获取更多信息和示例:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.