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