Reputation: 327
I have a requirement of reading subject, sender address and message body of new message in my Outlook inbox from a C# program. But I am getting security alert 'A Program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this'.
By some googling I found few third party COM libraries to avoid this. But I am looking for a solution which don't require any third party COM library.
Upvotes: 15
Views: 41386
Reputation: 3955
Another solution that works for me. Taken from https://learn.microsoft.com/en-us/archive/msdn-technet-forums/64c14bd3-0e7f-4ba9-b2bd-26cf62ce5883 .
This is similar to the answer above, but would work in case the option is grayed out.
Note: after an Outlook update, the setting might be reset. So consider double-checking the option if you find it not work.
Other methods are listed below.
.Display()
followed by pressing Enter to manually press the send button https://stackoverflow.com/a/25345147/5267751Upvotes: 1
Reputation: 1
You can disable the security pop-up using Outlook's Trust Center. Check here.
Upvotes: 0
Reputation: 608
We use Advanced Security for Outlook from Mapilab for this. It is free, also for commercial use, and still keeps Outlook safe (by only allowing access from approved applications). Just apposed to previously mentioned solutions that cost either money, or may compromise security.
Upvotes: 1
Reputation:
I ran into same issue while accessing sender email address for outlook mail item. To avoid 'security alert' do not create new Application object, instead use Globals.ThisAddIn.Application to create new mailitem.
string GetSenderEmail(Outlook.MailItem item)
{
string emailAddress = "";
if (item.SenderEmailType == "EX")
{
Outlook.MailItem tempItem = (Outlook.MailItem)Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem);
tempItem.To = item.SenderEmailAddress;
emailAddress = tempItem.Recipients[1].AddressEntry.GetExchangeUser().PrimarySmtpAddress.Trim();
}
else
{
emailAddress = item.SenderEmailAddress.Trim();
}
return emailAddress;
}
Upvotes: 15
Reputation: 4250
"But I am looking for a solution which don't require any third party COM library."
You won't find it. Kasper already pointed out the only solution that I know of. Redemption has been the only thing that has kept the Outlook plug-ins and code to work. I have done commercial Outlook add-ins for Franklin Covey. We explored a lot things, but Redemption was the only thing that got us over this hurdle.
Upvotes: 3
Reputation:
Try this
Tools-->Macro-->Security-->Programmatic Access
Then choose Never warn me about suspicious activity.
Upvotes: 5
Reputation: 1708
Sorry, I have had that annoying issue in both Outlook 2003 and Outlook 2007 add-ins, and the only solution that worked was to purchase a Redemption license. In Outlook 2007 that pesky popup should only show up if your firewall is down or your anti-virus software is outdated as far as I recall.
Upvotes: 10
Reputation: 21211
If your application is not a Outlook plug in you can look at MAPI to read data from the inbox
Upvotes: 1