Hello Ed,
Outlook does not native support this feature of choosing which application
should be trusted. For the concept of Outlook Security please refer to this
link:
http://www.outlookcode.com/article.aspx?ID=52
Personally, I agree with above article, thus, we have several choices to
avoid the prompt, such as use another API instead of Outlook Object Model,
due to your scenario, there are two options better than the other choices.
The first is use a third party add-in to set which application is trusted:
http://www.mapilab.com/outlook/security/
However this is a third party solution, we not tested any software or
information found on this site; therefore, Microsoft cannot make any
representations regarding the quality, safety, or suitability of any
software or information found there. There are inherent dangers in the use
of any software found on the Internet, and Microsoft cautions you to make
sure that you completely understand the risk before retrieving any software
from the Internet.
The second solution is we could write a VSTO add-in for Outlook, and expose
a method to send mail from that add-in, therefore, the mail actually is
sent by that in-process COM Add-in of Outlook, due to the security model of
Outlook, it will trust all COM Add-In by default, and we call the send mail
code of this add-in from other application will not trigger the security
prompt.
The concept of this method is list as below:
http://msdn.microsoft.com/en-us/library/bb226709.aspx
http://msdn.microsoft.com/en-us/library/bb608621.aspx
Here's a sample of this solution which I have tested in my side:
public partial class ThisAddIn
{
private AddInUtilities utilities;
protected override object RequestComAddInAutomationService()
{
if (utilities == null)
utilities = new AddInUtilities();
return utilities;
}
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
}
[ComVisible(true)]
public interface IAddInUtilities
{
void ImportData();
}
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class AddInUtilities : IAddInUtilities
{
public void ImportData()
{
Outlook.MailItem mi =
Globals.ThisAddIn.Application.CreateItem(Microsoft.Office.Interop.Outlook.Ol
ItemType.olMailItem) as Outlook.MailItem;
mi.To = "(e-mail address removed)";
mi.Subject = DateTime.Now.ToString();
mi.Send();
}
}
before we build this add-in we need to check the option in Project
Properties -> Application tab ->Assembly Information->COM Visible,
and Project Properties -> Build tab ->Register for COM interop.
In the other side I take a WinForm application for example, please note
that we have to cast the COMAddin.Object back to IAddInUtilities.
using OutlookAddInCallFromWinForm;
public Form1()
{
InitializeComponent();
Outlook.Application app =
Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
object index = 14;
OutlookAddInCallFromWinForm.IAddInUtilities iaddin =
app.COMAddIns.Item(ref index).Object as
OutlookAddInCallFromWinForm.IAddInUtilities;
iaddin.ImportData();
}
This code is in C# language, if you have any problem during translate it
into Visual Basic please feel free to follow up.
Best regards,
Tim Li
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).